/**
 * Copyright (c) 2021 OceanBase
 * OceanBase CE is licensed under Mulan PubL v2.
 * You can use this software according to the terms and conditions of the Mulan PubL v2.
 * You may obtain a copy of Mulan PubL v2 at:
 *          http://license.coscl.org.cn/MulanPubL-2.0
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PubL v2 for more details.
 */

#define USING_LOG_PREFIX SHARE_SCHEMA
#include "ob_inner_table_schema.h"

#include "share/schema/ob_schema_macro_define.h"
#include "share/schema/ob_schema_service_sql_impl.h"
#include "share/schema/ob_table_schema.h"

namespace oceanbase
{
using namespace share::schema;
using namespace common;
namespace share
{

int ObInnerTableSchema::dba_synonyms_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_DBA_SYNONYMS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_DBA_SYNONYMS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT       CASE WHEN       A.DATABASE_NAME = '__public' THEN       'PUBLIC' ELSE A.DATABASE_NAME END AS OWNER,       A.SYNONYM_NAME AS SYNONYM_NAME,       CAST(CASE WHEN INSTR(A.OBJECT_NAME, '@') = 0            THEN B.DATABASE_NAME            ELSE SUBSTR(A.OBJECT_NAME, 1, INSTR(A.OBJECT_NAME, '.') -1)            END            AS VARCHAR2(128)) AS TABLE_OWNER,       CAST(CASE WHEN INSTR(A.OBJECT_NAME, '@') = 0            THEN A.OBJECT_NAME            ELSE SUBSTR(A.OBJECT_NAME, INSTR(A.OBJECT_NAME, '.') + 1, INSTR(A.OBJECT_NAME, '@') - INSTR(A.OBJECT_NAME, '.') -1)            END            AS VARCHAR2(128)) AS TABLE_NAME,       CAST(CASE WHEN INSTR(A.OBJECT_NAME, '@') = 0                 THEN NULL                 ELSE SUBSTR(A.OBJECT_NAME, INSTR(A.OBJECT_NAME, '@')+1)                 END                 AS VARCHAR2(128)) AS DB_LINK     FROM       (SELECT BB.DATABASE_NAME, AA.SYNONYM_NAME,       AA.OBJECT_NAME, AA.SYNONYM_ID       FROM       SYS.ALL_VIRTUAL_SYNONYM_REAL_AGENT AA,       SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT BB       WHERE AA.DATABASE_ID = BB.DATABASE_ID         AND AA.TENANT_ID = EFFECTIVE_TENANT_ID()         AND BB.TENANT_ID = EFFECTIVE_TENANT_ID()) A,       (SELECT BB.DATABASE_NAME, AA.SYNONYM_ID       FROM       SYS.ALL_VIRTUAL_SYNONYM_REAL_AGENT AA,       SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT BB       WHERE AA.OBJECT_DATABASE_ID = BB.DATABASE_ID         AND AA.TENANT_ID = EFFECTIVE_TENANT_ID()         AND BB.TENANT_ID = EFFECTIVE_TENANT_ID()) B     WHERE       A.SYNONYM_ID = B.SYNONYM_ID )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::dba_objects_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_DBA_OBJECTS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_DBA_OBJECTS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT      B.DATABASE_NAME AS OWNER     ,CAST((CASE WHEN B.DATABASE_NAME = '__recyclebin' THEN A.OBJECT_NAME                 WHEN A.OBJECT_TYPE = 'INDEX' THEN SUBSTR(A.OBJECT_NAME, 7 + INSTR(SUBSTR(A.OBJECT_NAME, 7), '_'))            ELSE A.OBJECT_NAME END) AS VARCHAR2(128)) AS OBJECT_NAME     ,CAST(A.SUBOBJECT_NAME AS VARCHAR2(128)) AS SUBOBJECT_NAME     ,A.OBJECT_ID AS OBJECT_ID     ,CAST(A.DATA_OBJECT_ID AS NUMBER) AS DATA_OBJECT_ID     ,CAST(A.OBJECT_TYPE AS VARCHAR2(23)) AS OBJECT_TYPE     ,CAST(A.GMT_CREATE AS DATE) AS CREATED     ,CAST(A.GMT_MODIFIED AS DATE) AS LAST_DDL_TIME     ,TO_CHAR(A.GMT_CREATE) AS TIMESTAMP     ,CAST(A.STATUS AS VARCHAR2(7)) AS STATUS     ,CAST(A.TEMPORARY AS VARCHAR2(1)) AS TEMPORARY     ,CAST("GENERATED" AS VARCHAR2(1)) AS "GENERATED"     ,CAST(A.SECONDARY AS VARCHAR2(1)) AS SECONDARY     ,CAST(A.NAMESPACE AS NUMBER) AS NAMESPACE     ,CAST(A.EDITION_NAME AS VARCHAR2(128)) AS EDITION_NAME     FROM (     SELECT     GMT_CREATE     ,GMT_MODIFIED     ,DATABASE_ID     ,TABLE_NAME OBJECT_NAME     ,NULL SUBOBJECT_NAME     ,TABLE_ID OBJECT_ID     ,NULL DATA_OBJECT_ID     ,CASE WHEN TABLE_TYPE IN (0,2,3,6,8,9,10) THEN 'TABLE'           WHEN TABLE_TYPE IN (1,4) THEN 'VIEW'           WHEN TABLE_TYPE IN (5) THEN 'INDEX'           WHEN TABLE_TYPE IN (7) THEN 'MATERIALIZED VIEW'           ELSE NULL END AS OBJECT_TYPE     ,CAST(CASE WHEN TABLE_TYPE IN (5) THEN CASE WHEN INDEX_STATUS = 2 THEN 'VALID'             WHEN INDEX_STATUS = 3 THEN 'CHECKING'             WHEN INDEX_STATUS = 4 THEN 'INELEGIBLE'             WHEN INDEX_STATUS = 5 THEN 'ERROR'             ELSE 'UNUSABLE' END           ELSE  'VALID' END AS VARCHAR2(10)) AS STATUS     ,CASE WHEN TABLE_TYPE IN (6,8,9,10) THEN 'Y'         ELSE 'N' END AS TEMPORARY     ,CASE WHEN TABLE_TYPE IN (0,1) THEN 'Y'         ELSE 'N' END AS "GENERATED"     ,'N' AS SECONDARY     , 0 AS NAMESPACE     ,NULL AS EDITION_NAME     FROM     SYS.ALL_VIRTUAL_TABLE_REAL_AGENT     WHERE TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     P.GMT_CREATE     ,P.GMT_MODIFIED     ,T.DATABASE_ID     ,T.TABLE_NAME OBJECT_NAME     ,P.PART_NAME SUBOBJECT_NAME     ,P.PART_ID OBJECT_ID     ,CASE WHEN P.PART_IDX != -1 THEN P.PART_ID ELSE NULL END AS DATA_OBJECT_ID     ,'TABLE PARTITION' AS OBJECT_TYPE     ,'VALID' AS STATUS     ,'N' AS TEMPORARY     ,CASE WHEN P.PART_IDX != -1 THEN 'Y'         ELSE 'N' END AS "GENERATED"     ,'N' AS SECONDARY     , 0 AS NAMESPACE     ,NULL AS EDITION_NAME     FROM SYS.ALL_VIRTUAL_TABLE_REAL_AGENT T JOIN SYS.ALL_VIRTUAL_PART_REAL_AGENT P ON T.TABLE_ID = P.TABLE_ID     WHERE T.TENANT_ID = EFFECTIVE_TENANT_ID() AND P.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     SUBP.GMT_CREATE     ,SUBP.GMT_MODIFIED     ,T.DATABASE_ID     ,T.TABLE_NAME OBJECT_NAME     ,SUBP.SUB_PART_NAME SUBOBJECT_NAME     ,SUBP.PART_ID OBJECT_ID     ,SUBP.PART_ID AS DATA_OBJECT_ID     ,'TABLE SUBPARTITION' AS OBJECT_TYPE     ,'VALID' AS STATUS     ,'N' AS TEMPORARY     ,'Y' AS "GENERATED"     ,'N' AS SECONDARY     , 0 AS NAMESPACE     ,NULL AS EDITION_NAME     FROM SYS.ALL_VIRTUAL_TABLE_REAL_AGENT T, SYS.ALL_VIRTUAL_PART_REAL_AGENT P,SYS.ALL_VIRTUAL_SUB_PART_REAL_AGENT SUBP     WHERE T.TABLE_ID =P.TABLE_ID AND P.TABLE_ID=SUBP.TABLE_ID AND P.PART_ID =SUBP.PART_ID     AND T.TENANT_ID = EFFECTIVE_TENANT_ID() AND P.TENANT_ID = EFFECTIVE_TENANT_ID() AND SUBP.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     P.GMT_CREATE     ,P.GMT_MODIFIED     ,P.DATABASE_ID     ,P.PACKAGE_NAME AS OBJECT_NAME     ,NULL AS SUBOBJECT_NAME     ,P.PACKAGE_ID OBJECT_ID     ,NULL AS DATA_OBJECT_ID     ,CASE WHEN TYPE = 1 THEN 'PACKAGE'           WHEN TYPE = 2 THEN 'PACKAGE BODY'           ELSE NULL END AS OBJECT_TYPE     ,CASE WHEN EXISTS                 (SELECT OBJ_ID FROM SYS.ALL_VIRTUAL_TENANT_ERROR_REAL_AGENT E                   WHERE P.TENANT_ID = E.TENANT_ID AND P.PACKAGE_ID = E.OBJ_ID AND (E.OBJ_TYPE = 3 OR E.OBJ_TYPE = 5))                THEN 'INVALID'           ELSE 'VALID' END AS STATUS     ,'N' AS TEMPORARY     ,'N' AS "GENERATED"     ,'N' AS SECONDARY     , 0 AS NAMESPACE     ,NULL AS EDITION_NAME     FROM SYS.ALL_VIRTUAL_PACKAGE_REAL_AGENT P     WHERE P.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     R.GMT_CREATE     ,R.GMT_MODIFIED     ,R.DATABASE_ID     ,R.ROUTINE_NAME AS OBJECT_NAME     ,NULL AS SUBOBJECT_NAME     ,R.ROUTINE_ID OBJECT_ID     ,NULL AS DATA_OBJECT_ID     ,CASE WHEN ROUTINE_TYPE = 1 THEN 'PROCEDURE'           WHEN ROUTINE_TYPE = 2 THEN 'FUNCTION'           ELSE NULL END AS OBJECT_TYPE     ,CASE WHEN EXISTS                 (SELECT OBJ_ID FROM SYS.ALL_VIRTUAL_TENANT_ERROR_REAL_AGENT E                   WHERE R.TENANT_ID = E.TENANT_ID AND R.ROUTINE_ID = E.OBJ_ID AND (E.OBJ_TYPE = 9 OR E.OBJ_TYPE = 12))                THEN 'INVALID'           ELSE 'VALID' END AS STATUS     ,'N' AS TEMPORARY     ,'N' AS "GENERATED"     ,'N' AS SECONDARY     , 0 AS NAMESPACE     ,NULL AS EDITION_NAME     FROM SYS.ALL_VIRTUAL_ROUTINE_REAL_AGENT R     WHERE (ROUTINE_TYPE = 1 OR ROUTINE_TYPE = 2) AND R.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     T.GMT_CREATE     ,T.GMT_MODIFIED     ,T.DATABASE_ID     ,T.TRIGGER_NAME AS OBJECT_NAME     ,NULL AS SUBOBJECT_NAME     ,T.TRIGGER_ID OBJECT_ID     ,NULL AS DATA_OBJECT_ID     ,'TRIGGER' OBJECT_TYPE     ,CASE WHEN EXISTS                 (SELECT OBJ_ID FROM SYS.ALL_VIRTUAL_ERROR_AGENT E                   WHERE T.TENANT_ID = E.TENANT_ID AND T.TRIGGER_ID = E.OBJ_ID AND (E.OBJ_TYPE = 7))                THEN 'INVALID'           ELSE 'VALID' END AS STATUS     ,'N' AS TEMPORARY     ,'N' AS "GENERATED"     ,'N' AS SECONDARY     , 0 AS NAMESPACE     ,NULL AS EDITION_NAME     FROM SYS.ALL_VIRTUAL_TRIGGER_AGENT T     WHERE T.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     GMT_CREATE     ,GMT_MODIFIED     ,DATABASE_ID     ,SYNONYM_NAME AS OBJECT_NAME     ,NULL AS SUBOBJECT_NAME     ,SYNONYM_ID OBJECT_ID     ,NULL AS DATA_OBJECT_ID     ,'SYNONYM' AS OBJECT_TYPE     ,'VALID' AS STATUS     ,'N' AS TEMPORARY     ,'N' AS "GENERATED"     ,'N' AS SECONDARY     , 0 AS NAMESPACE     ,NULL AS EDITION_NAME     FROM SYS.ALL_VIRTUAL_SYNONYM_REAL_AGENT     WHERE TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     GMT_CREATE     ,GMT_MODIFIED     ,DATABASE_ID     ,SEQUENCE_NAME AS OBJECT_NAME     ,NULL AS SUBOBJECT_NAME     ,SEQUENCE_ID OBJECT_ID     ,NULL AS DATA_OBJECT_ID     ,'SEQUENCE' AS OBJECT_TYPE     ,'VALID' AS STATUS     ,'N' AS TEMPORARY     ,'N' AS "GENERATED"     ,'N' AS SECONDARY     , 0 AS NAMESPACE     ,NULL AS EDITION_NAME     FROM SYS.ALL_VIRTUAL_SEQUENCE_OBJECT_REAL_AGENT     WHERE TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     GMT_CREATE     ,GMT_MODIFIED     ,DATABASE_ID     ,TYPE_NAME AS OBJECT_NAME     ,NULL AS SUBOBJECT_NAME     ,TYPE_ID OBJECT_ID     ,NULL AS DATA_OBJECT_ID     ,'TYPE' AS OBJECT_TYPE     ,'VALID' AS STATUS     ,'N' AS TEMPORARY     ,'N' AS "GENERATED"     ,'N' AS SECONDARY     , 0 AS NAMESPACE     ,NULL AS EDITION_NAME     FROM SYS.ALL_VIRTUAL_TYPE_REAL_AGENT     WHERE TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     GMT_CREATE     ,GMT_MODIFIED     ,DATABASE_ID     ,OBJECT_NAME     ,NULL AS SUBOBJECT_NAME     ,OBJECT_TYPE_ID OBJECT_ID     ,NULL AS DATA_OBJECT_ID     ,'TYPE BODY' AS OBJECT_TYPE     ,'VALID' AS STATUS     ,'N' AS TEMPORARY     ,'N' AS "GENERATED"     ,'N' AS SECONDARY     , 0 AS NAMESPACE     ,NULL AS EDITION_NAME     FROM SYS.ALL_VIRTUAL_OBJECT_TYPE_AGENT     WHERE TENANT_ID = EFFECTIVE_TENANT_ID() and TYPE = 2     )A     JOIN SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT B     ON A.DATABASE_ID = B.DATABASE_ID     AND B.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT       'SYS' AS OWNER       ,TS.TYPE_NAME AS OBJECT_NAME       ,NULL AS SUBOBJECT_NAME       ,TS.TYPE_ID AS OBJECT_ID       ,NULL AS DATA_OBJECT_ID       ,'TYPE' AS OBJECT_TYPE       ,CAST(TS.GMT_CREATE AS DATE) AS CREATED       ,CAST(TS.GMT_MODIFIED AS DATE) AS LAST_DDL_TIME       ,TO_CHAR(TS.GMT_CREATE) AS TIMESTAMP       ,'VALID' AS STATUS       ,'N' AS TEMPORARY       ,'N' AS "GENERATED"       ,'N' AS SECONDARY       ,0 AS NAMESPACE       ,NULL AS EDITION_NAME   FROM SYS.ALL_VIRTUAL_TYPE_SYS_AGENT TS   UNION ALL   SELECT     'SYS' AS OWNER     ,PACKAGE_NAME AS OBJECT_NAME     ,NULL AS SUBOBJECT_NAME     ,PACKAGE_ID OBJECT_ID     ,NULL AS DATA_OBJECT_ID     ,CASE WHEN TYPE = 1 THEN 'PACKAGE'           WHEN TYPE = 2 THEN 'PACKAGE BODY'           ELSE NULL END AS OBJECT_TYPE     ,CAST(GMT_CREATE AS DATE) AS CREATED     ,CAST(GMT_MODIFIED AS DATE) AS LAST_DDL_TIME     ,TO_CHAR(GMT_CREATE) AS TIMESTAMP     ,'VALID' AS STATUS     ,'N' AS TEMPORARY     ,'N' AS "GENERATED"     ,'N' AS SECONDARY     ,0 AS NAMESPACE     ,NULL AS EDITION_NAME   FROM SYS.ALL_VIRTUAL_PACKAGE_SYS_AGENT   UNION ALL   SELECT      'SYS' AS OWNER      ,ROUTINE_NAME AS OBJECT_NAME      ,NULL AS SUBOBJECT_NAME      ,ROUTINE_ID OBJECT_ID      ,NULL AS DATA_OBJECT_ID      ,CASE WHEN ROUTINE_TYPE = 1 THEN 'PROCEDURE'            WHEN ROUTINE_TYPE = 2 THEN 'FUNCTION'            ELSE NULL END AS OBJECT_TYPE      ,CAST(GMT_CREATE AS DATE) AS CREATED      ,CAST(GMT_MODIFIED AS DATE) AS LAST_DDL_TIME      ,TO_CHAR(GMT_CREATE) AS TIMESTAMP      ,'VALID' AS STATUS      ,'N' AS TEMPORARY      ,'N' AS "GENERATED"      ,'N' AS SECONDARY      ,0 AS NAMESPACE      ,NULL AS EDITION_NAME    FROM SYS.ALL_VIRTUAL_ROUTINE_SYS_AGENT    UNION ALL    SELECT      'SYS' AS OWNER      ,TRIGGER_NAME AS OBJECT_NAME      ,NULL AS SUBOBJECT_NAME      ,TRIGGER_ID OBJECT_ID      ,NULL AS DATA_OBJECT_ID      ,'TRIGGER' AS OBJECT_TYPE      ,CAST(GMT_CREATE AS DATE) AS CREATED      ,CAST(GMT_MODIFIED AS DATE) AS LAST_DDL_TIME      ,TO_CHAR(GMT_CREATE) AS TIMESTAMP      ,'VALID' AS STATUS      ,'N' AS TEMPORARY      ,'N' AS "GENERATED"      ,'N' AS SECONDARY      ,0 AS NAMESPACE      ,NULL AS EDITION_NAME    FROM SYS.ALL_VIRTUAL_TENANT_TRIGGER_SYS_AGENT )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::all_objects_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_ALL_OBJECTS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_ALL_OBJECTS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT      B.DATABASE_NAME AS OWNER      ,CAST((CASE WHEN B.DATABASE_NAME = '__recyclebin' THEN A.OBJECT_NAME                  WHEN A.OBJECT_TYPE = 'INDEX' THEN SUBSTR(A.OBJECT_NAME, 7 + INSTR(SUBSTR(A.OBJECT_NAME, 7), '_'))             ELSE A.OBJECT_NAME END) AS VARCHAR2(128)) AS OBJECT_NAME     ,CAST(A.SUBOBJECT_NAME AS VARCHAR2(128)) AS SUBOBJECT_NAME     ,A.OBJECT_ID AS OBJECT_ID     ,CAST(A.DATA_OBJECT_ID AS NUMBER) AS DATA_OBJECT_ID     ,CAST(A.OBJECT_TYPE AS VARCHAR2(23)) AS OBJECT_TYPE     ,CAST(A.GMT_CREATE AS DATE) AS CREATED     ,CAST(A.GMT_MODIFIED AS DATE) AS LAST_DDL_TIME     ,TO_CHAR(A.GMT_CREATE) AS TIMESTAMP     ,CAST(A.STATUS AS VARCHAR2(7)) AS STATUS     ,CAST(A.TEMPORARY AS VARCHAR2(1)) AS TEMPORARY     ,CAST("GENERATED" AS VARCHAR2(1)) AS "GENERATED"     ,CAST(A.SECONDARY AS VARCHAR2(1)) AS SECONDARY     ,CAST(A.NAMESPACE AS NUMBER) AS NAMESPACE     ,CAST(A.EDITION_NAME AS VARCHAR2(128)) AS EDITION_NAME     FROM (     SELECT     GMT_CREATE     ,GMT_MODIFIED     ,DATABASE_ID     ,TABLE_NAME OBJECT_NAME     ,NULL SUBOBJECT_NAME     ,TABLE_ID OBJECT_ID     ,NULL DATA_OBJECT_ID     ,CASE WHEN TABLE_TYPE IN (0,2,3,6,8,9,10) THEN 'TABLE'           WHEN TABLE_TYPE IN (1,4) THEN 'VIEW'           WHEN TABLE_TYPE IN (5) THEN 'INDEX'           WHEN TABLE_TYPE IN (7) THEN 'MATERIALIZED VIEW'           ELSE NULL END AS OBJECT_TYPE     ,CAST(CASE WHEN TABLE_TYPE IN (5) THEN CASE WHEN INDEX_STATUS = 2 THEN 'VALID'             WHEN INDEX_STATUS = 3 THEN 'CHECKING'             WHEN INDEX_STATUS = 4 THEN 'INELEGIBLE'             WHEN INDEX_STATUS = 5 THEN 'ERROR'             ELSE 'UNUSABLE' END           ELSE  'VALID' END AS VARCHAR2(10)) AS STATUS     ,CASE WHEN TABLE_TYPE IN (6,8,9,10) THEN 'Y'         ELSE 'N' END AS TEMPORARY     ,CASE WHEN TABLE_TYPE IN (0,1) THEN 'Y'         ELSE 'N' END AS "GENERATED"     ,'N' AS SECONDARY     , 0 AS NAMESPACE     ,NULL AS EDITION_NAME     , CASE WHEN TABLE_TYPE IN (5) THEN DATA_TABLE_ID            ELSE TABLE_ID END AS PRIV_OBJECT_ID     FROM     SYS.ALL_VIRTUAL_TABLE_REAL_AGENT     WHERE TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     P.GMT_CREATE     ,P.GMT_MODIFIED     ,T.DATABASE_ID     ,T.TABLE_NAME OBJECT_NAME     ,P.PART_NAME SUBOBJECT_NAME     ,P.PART_ID OBJECT_ID     ,CASE WHEN P.PART_IDX != -1 THEN P.PART_ID ELSE NULL END AS DATA_OBJECT_ID     ,'TABLE PARTITION' AS OBJECT_TYPE     ,'VALID' AS STATUS     ,'N' AS TEMPORARY     ,CASE WHEN P.PART_IDX != -1 THEN 'Y'         ELSE 'N' END AS "GENERATED"     ,'N' AS SECONDARY     , 0 AS NAMESPACE     ,NULL AS EDITION_NAME     ,T.TABLE_ID AS PRIV_OBJECT_ID     FROM SYS.ALL_VIRTUAL_TABLE_REAL_AGENT T JOIN SYS.ALL_VIRTUAL_PART_REAL_AGENT P ON T.TABLE_ID = P.TABLE_ID     WHERE T.TENANT_ID = EFFECTIVE_TENANT_ID() AND P.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     SUBP.GMT_CREATE     ,SUBP.GMT_MODIFIED     ,T.DATABASE_ID     ,T.TABLE_NAME OBJECT_NAME     ,SUBP.SUB_PART_NAME SUBOBJECT_NAME     ,SUBP.PART_ID OBJECT_ID     ,SUBP.PART_ID AS DATA_OBJECT_ID     ,'TABLE SUBPARTITION' AS OBJECT_TYPE     ,'VALID' AS STATUS     ,'N' AS TEMPORARY     ,'Y' AS "GENERATED"     ,'N' AS SECONDARY     , 0 AS NAMESPACE     ,NULL AS EDITION_NAME     ,T.TABLE_ID AS PRIV_OBJECT_ID     FROM SYS.ALL_VIRTUAL_TABLE_REAL_AGENT T, SYS.ALL_VIRTUAL_PART_REAL_AGENT P,SYS.ALL_VIRTUAL_SUB_PART_REAL_AGENT SUBP     WHERE T.TABLE_ID =P.TABLE_ID AND P.TABLE_ID=SUBP.TABLE_ID AND P.PART_ID =SUBP.PART_ID       AND T.TENANT_ID = EFFECTIVE_TENANT_ID() AND P.TENANT_ID = EFFECTIVE_TENANT_ID() AND SUBP.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     P.GMT_CREATE     ,P.GMT_MODIFIED     ,P.DATABASE_ID     ,P.PACKAGE_NAME AS OBJECT_NAME     ,NULL AS SUBOBJECT_NAME     ,P.PACKAGE_ID OBJECT_ID     ,NULL AS DATA_OBJECT_ID     ,CASE WHEN TYPE = 1 THEN 'PACKAGE'           WHEN TYPE = 2 THEN 'PACKAGE BODY'           ELSE NULL END AS OBJECT_TYPE     ,CASE WHEN EXISTS                 (SELECT OBJ_ID FROM SYS.ALL_VIRTUAL_TENANT_ERROR_REAL_AGENT E                   WHERE P.TENANT_ID = E.TENANT_ID AND P.PACKAGE_ID = E.OBJ_ID AND (E.OBJ_TYPE = 3 OR E.OBJ_TYPE = 5))                THEN 'INVALID'           ELSE 'VALID' END AS STATUS     ,'N' AS TEMPORARY     ,'N' AS "GENERATED"     ,'N' AS SECONDARY     , 0 AS NAMESPACE     ,NULL AS EDITION_NAME     ,P.PACKAGE_ID AS PRIV_OBJECT_ID     FROM SYS.ALL_VIRTUAL_PACKAGE_REAL_AGENT P     WHERE P.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     R.GMT_CREATE     ,R.GMT_MODIFIED     ,R.DATABASE_ID     ,R.ROUTINE_NAME AS OBJECT_NAME     ,NULL AS SUBOBJECT_NAME     ,ROUTINE_ID OBJECT_ID     ,NULL AS DATA_OBJECT_ID     ,CASE WHEN ROUTINE_TYPE = 1 THEN 'PROCEDURE'           WHEN ROUTINE_TYPE = 2 THEN 'FUNCTION'           ELSE NULL END AS OBJECT_TYPE     ,CASE WHEN EXISTS                 (SELECT OBJ_ID FROM SYS.ALL_VIRTUAL_TENANT_ERROR_REAL_AGENT E                   WHERE R.TENANT_ID = E.TENANT_ID AND R.ROUTINE_ID = E.OBJ_ID AND (E.OBJ_TYPE = 9 OR E.OBJ_TYPE = 12))                THEN 'INVALID'           ELSE 'VALID' END AS STATUS     ,'N' AS TEMPORARY     ,'N' AS "GENERATED"     ,'N' AS SECONDARY     , 0 AS NAMESPACE     ,NULL AS EDITION_NAME     ,ROUTINE_ID AS PRIV_OBJECT_ID     FROM SYS.ALL_VIRTUAL_ROUTINE_REAL_AGENT R     WHERE (ROUTINE_TYPE = 1 OR ROUTINE_TYPE = 2) AND R.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     T.GMT_CREATE     ,T.GMT_MODIFIED     ,T.DATABASE_ID     ,T.TRIGGER_NAME AS OBJECT_NAME     ,NULL AS SUBOBJECT_NAME     ,T.TRIGGER_ID OBJECT_ID     ,NULL AS DATA_OBJECT_ID     ,'TRIGGER' OBJECT_TYPE     ,CASE WHEN EXISTS                 (SELECT OBJ_ID FROM SYS.ALL_VIRTUAL_ERROR_AGENT E                   WHERE T.TENANT_ID = E.TENANT_ID AND T.TRIGGER_ID = E.OBJ_ID AND (E.OBJ_TYPE = 7))                THEN 'INVALID'           ELSE 'VALID' END AS STATUS     ,'N' AS TEMPORARY     ,'N' AS "GENERATED"     ,'N' AS SECONDARY     , 0 AS NAMESPACE     ,NULL AS EDITION_NAME     ,T.TRIGGER_ID AS PRIV_OBJECT_ID     FROM SYS.ALL_VIRTUAL_TRIGGER_AGENT T     WHERE T.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     GMT_CREATE     ,GMT_MODIFIED     ,DATABASE_ID     ,SYNONYM_NAME AS OBJECT_NAME     ,NULL AS SUBOBJECT_NAME     ,SYNONYM_ID OBJECT_ID     ,NULL AS DATA_OBJECT_ID     ,'SYNONYM' AS OBJECT_TYPE     ,'VALID' AS STATUS     ,'N' AS TEMPORARY     ,'N' AS "GENERATED"     ,'N' AS SECONDARY     , 0 AS NAMESPACE     ,NULL AS EDITION_NAME     ,SYNONYM_ID AS PRIV_OBJECT_ID     FROM SYS.ALL_VIRTUAL_SYNONYM_REAL_AGENT     WHERE TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     GMT_CREATE     ,GMT_MODIFIED     ,DATABASE_ID     ,SEQUENCE_NAME AS OBJECT_NAME     ,NULL AS SUBOBJECT_NAME     ,SEQUENCE_ID OBJECT_ID     ,NULL AS DATA_OBJECT_ID     ,'SEQUENCE' AS OBJECT_TYPE     ,'VALID' AS STATUS     ,'N' AS TEMPORARY     ,'N' AS "GENERATED"     ,'N' AS SECONDARY     , 0 AS NAMESPACE     ,NULL AS EDITION_NAME     ,SEQUENCE_ID AS PRIV_OBJECT_ID     FROM SYS.ALL_VIRTUAL_SEQUENCE_OBJECT_REAL_AGENT     WHERE TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     GMT_CREATE     ,GMT_MODIFIED     ,DATABASE_ID     ,TYPE_NAME AS OBJECT_NAME     ,NULL AS SUBOBJECT_NAME     ,TYPE_ID OBJECT_ID     ,NULL AS DATA_OBJECT_ID     ,'TYPE' AS OBJECT_TYPE     ,'VALID' AS STATUS     ,'N' AS TEMPORARY     ,'N' AS "GENERATED"     ,'N' AS SECONDARY     , 0 AS NAMESPACE     ,NULL AS EDITION_NAME     ,TYPE_ID AS PRIV_OBJECT_ID     FROM SYS.ALL_VIRTUAL_TYPE_REAL_AGENT     WHERE TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     GMT_CREATE     ,GMT_MODIFIED     ,DATABASE_ID     ,OBJECT_NAME     ,NULL AS SUBOBJECT_NAME     ,OBJECT_TYPE_ID OBJECT_ID     ,NULL AS DATA_OBJECT_ID     ,'TYPE BODY' AS OBJECT_TYPE     ,'VALID' AS STATUS     ,'N' AS TEMPORARY     ,'N' AS "GENERATED"     ,'N' AS SECONDARY     , 0 AS NAMESPACE     ,NULL AS EDITION_NAME     ,OBJECT_TYPE_ID AS PRIV_OBJECT_ID     FROM SYS.ALL_VIRTUAL_OBJECT_TYPE_AGENT     WHERE TENANT_ID = EFFECTIVE_TENANT_ID() and TYPE = 2     )A     JOIN SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT B     ON A.DATABASE_ID = B.DATABASE_ID     AND B.TENANT_ID = EFFECTIVE_TENANT_ID()     AND (A.DATABASE_ID = USERENV('SCHEMAID')              or USER_CAN_ACCESS_OBJ(DECODE(OBJECT_TYPE, 'TABLE', 1,                                                         'VIEW', 1,                                                         'INDEX', 1,                                                         'MATERIALIZED VIEW',9,                                                         'TABLE PARTITION',1,                                                         'TABLE SUBPARTITION', 1,                                                         'PACKAGE', 3,                                                         'PACKAGE BODY', 3,                                                         'PROCEDURE', 12,                                                         'FUNCTION', 9,                                                         'SYNONYM', 13,                                                         'SEQUENCE', 2,                                                         'TYPE', 4,                                                         1), A.PRIV_OBJECT_ID, A.DATABASE_ID) =1       )   UNION ALL   SELECT     'SYS' AS OWNER     ,TS.TYPE_NAME AS OBJECT_NAME     ,NULL AS SUBOBJECT_NAME     ,TS.TYPE_ID AS OBJECT_ID     ,NULL AS DATA_OBJECT_ID     ,'TYPE' AS OBJECT_TYPE     ,CAST(TS.GMT_CREATE AS DATE) AS CREATED     ,CAST(TS.GMT_MODIFIED AS DATE) AS LAST_DDL_TIME     ,TO_CHAR(TS.GMT_CREATE) AS TIMESTAMP     ,'VALID' AS STATUS     ,'N' AS TEMPORARY     ,'N' AS "GENERATED"     ,'N' AS SECONDARY     ,0 AS NAMESPACE     ,NULL AS EDITION_NAME   FROM SYS.ALL_VIRTUAL_TYPE_SYS_AGENT TS   UNION ALL   SELECT     'SYS' AS OWNER     ,PACKAGE_NAME AS OBJECT_NAME     ,NULL AS SUBOBJECT_NAME     ,PACKAGE_ID OBJECT_ID     ,NULL AS DATA_OBJECT_ID     ,CASE WHEN TYPE = 1 THEN 'PACKAGE'           WHEN TYPE = 2 THEN 'PACKAGE BODY'           ELSE NULL END AS OBJECT_TYPE     ,CAST(GMT_CREATE AS DATE) AS CREATED     ,CAST(GMT_MODIFIED AS DATE) AS LAST_DDL_TIME     ,TO_CHAR(GMT_CREATE) AS TIMESTAMP     ,'VALID' AS STATUS     ,'N' AS TEMPORARY     ,'N' AS "GENERATED"     ,'N' AS SECONDARY     ,0 AS NAMESPACE     ,NULL AS EDITION_NAME   FROM SYS.ALL_VIRTUAL_PACKAGE_SYS_AGENT   UNION ALL   SELECT     'SYS' AS OWNER     ,ROUTINE_NAME AS OBJECT_NAME     ,NULL AS SUBOBJECT_NAME     ,ROUTINE_ID OBJECT_ID     ,NULL AS DATA_OBJECT_ID     ,CASE WHEN ROUTINE_TYPE = 1 THEN 'PROCEDURE'           WHEN ROUTINE_TYPE = 2 THEN 'FUNCTION'           ELSE NULL END AS OBJECT_TYPE     ,CAST(GMT_CREATE AS DATE) AS CREATED     ,CAST(GMT_MODIFIED AS DATE) AS LAST_DDL_TIME     ,TO_CHAR(GMT_CREATE) AS TIMESTAMP     ,'VALID' AS STATUS     ,'N' AS TEMPORARY     ,'N' AS "GENERATED"     ,'N' AS SECONDARY     ,0 AS NAMESPACE     ,NULL AS EDITION_NAME   FROM SYS.ALL_VIRTUAL_ROUTINE_SYS_AGENT   UNION ALL   SELECT     'SYS' AS OWNER     ,TRIGGER_NAME AS OBJECT_NAME     ,NULL AS SUBOBJECT_NAME     ,TRIGGER_ID OBJECT_ID     ,NULL AS DATA_OBJECT_ID     ,'TRIGGER' AS OBJECT_TYPE     ,CAST(GMT_CREATE AS DATE) AS CREATED     ,CAST(GMT_MODIFIED AS DATE) AS LAST_DDL_TIME     ,TO_CHAR(GMT_CREATE) AS TIMESTAMP     ,'VALID' AS STATUS     ,'N' AS TEMPORARY     ,'N' AS "GENERATED"     ,'N' AS SECONDARY     ,0 AS NAMESPACE     ,NULL AS EDITION_NAME   FROM SYS.ALL_VIRTUAL_TENANT_TRIGGER_SYS_AGENT )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::user_objects_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_USER_OBJECTS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_USER_OBJECTS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT     CAST((CASE WHEN A.OBJECT_TYPE = 'INDEX' THEN SUBSTR(A.OBJECT_NAME, 7 + INSTR(SUBSTR(A.OBJECT_NAME, 7), '_'))                ELSE A.OBJECT_NAME END) AS VARCHAR2(128)) AS OBJECT_NAME     ,CAST(A.SUBOBJECT_NAME AS VARCHAR2(128)) AS SUBOBJECT_NAME     ,A.OBJECT_ID AS OBJECT_ID     ,CAST(A.DATA_OBJECT_ID AS NUMBER) AS DATA_OBJECT_ID     ,CAST(A.OBJECT_TYPE AS VARCHAR2(23)) AS OBJECT_TYPE     ,CAST(A.GMT_CREATE AS DATE) AS CREATED     ,CAST(A.GMT_MODIFIED AS DATE) AS LAST_DDL_TIME     ,TO_CHAR(A.GMT_CREATE) AS TIMESTAMP     ,CAST(A.STATUS AS VARCHAR2(7)) AS STATUS     ,CAST(A.TEMPORARY AS VARCHAR2(1)) AS TEMPORARY     ,CAST("GENERATED" AS VARCHAR2(1)) AS "GENERATED"     ,CAST(A.SECONDARY AS VARCHAR2(1)) AS SECONDARY     ,CAST(A.NAMESPACE AS NUMBER) AS NAMESPACE     ,CAST(A.EDITION_NAME AS VARCHAR2(128)) AS EDITION_NAME     FROM (     SELECT     GMT_CREATE     ,GMT_MODIFIED     ,DATABASE_ID     ,TABLE_NAME OBJECT_NAME     ,NULL SUBOBJECT_NAME     ,TABLE_ID OBJECT_ID     ,NULL DATA_OBJECT_ID     ,CASE WHEN TABLE_TYPE IN (0,2,3,6,8,9,10) THEN 'TABLE'           WHEN TABLE_TYPE IN (1,4) THEN 'VIEW'           WHEN TABLE_TYPE IN (5) THEN 'INDEX'           WHEN TABLE_TYPE IN (7) THEN 'MATERIALIZED VIEW'           ELSE NULL END AS OBJECT_TYPE     ,CAST(CASE WHEN TABLE_TYPE IN (5) THEN CASE WHEN INDEX_STATUS = 2 THEN 'VALID'             WHEN INDEX_STATUS = 3 THEN 'CHECKING'             WHEN INDEX_STATUS = 4 THEN 'INELEGIBLE'             WHEN INDEX_STATUS = 5 THEN 'ERROR'             ELSE 'UNUSABLE' END            ELSE  'VALID' END AS VARCHAR2(10)) AS STATUS     ,CASE WHEN TABLE_TYPE IN (6,8,9,10) THEN 'Y'         ELSE 'N' END AS TEMPORARY     ,CASE WHEN TABLE_TYPE IN (0,1) THEN 'Y'         ELSE 'N' END AS "GENERATED"     ,'N' AS SECONDARY     , 0 AS NAMESPACE     ,NULL AS EDITION_NAME     FROM     SYS.ALL_VIRTUAL_TABLE_REAL_AGENT     WHERE TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     P.GMT_CREATE     ,P.GMT_MODIFIED     ,T.DATABASE_ID     ,T.TABLE_NAME OBJECT_NAME     ,P.PART_NAME SUBOBJECT_NAME     ,P.PART_ID OBJECT_ID     ,CASE WHEN P.PART_IDX != -1 THEN P.PART_ID ELSE NULL END AS DATA_OBJECT_ID     ,'TABLE PARTITION' AS OBJECT_TYPE     ,'VALID' AS STATUS     ,'N' AS TEMPORARY     ,CASE WHEN P.PART_IDX != -1 THEN 'Y'         ELSE 'N' END AS "GENERATED"     ,'N' AS SECONDARY     , 0 AS NAMESPACE     ,NULL AS EDITION_NAME     FROM SYS.ALL_VIRTUAL_TABLE_REAL_AGENT T JOIN SYS.ALL_VIRTUAL_PART_REAL_AGENT P ON T.TABLE_ID = P.TABLE_ID     WHERE T.TENANT_ID = EFFECTIVE_TENANT_ID() AND P.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     SUBP.GMT_CREATE     ,SUBP.GMT_MODIFIED     ,T.DATABASE_ID     ,T.TABLE_NAME OBJECT_NAME     ,SUBP.SUB_PART_NAME SUBOBJECT_NAME     ,SUBP.PART_ID OBJECT_ID     ,SUBP.PART_ID AS DATA_OBJECT_ID     ,'TABLE SUBPARTITION' AS OBJECT_TYPE     ,'VALID' AS STATUS     ,'N' AS TEMPORARY     ,'Y' AS "GENERATED"     ,'N' AS SECONDARY     , 0 AS NAMESPACE     ,NULL AS EDITION_NAME     FROM SYS.ALL_VIRTUAL_TABLE_REAL_AGENT T, SYS.ALL_VIRTUAL_PART_REAL_AGENT P,SYS.ALL_VIRTUAL_SUB_PART_REAL_AGENT SUBP     WHERE T.TABLE_ID =P.TABLE_ID AND P.TABLE_ID=SUBP.TABLE_ID AND P.PART_ID =SUBP.PART_ID     AND T.TENANT_ID = EFFECTIVE_TENANT_ID() AND P.TENANT_ID = EFFECTIVE_TENANT_ID() AND SUBP.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     P.GMT_CREATE     ,P.GMT_MODIFIED     ,P.DATABASE_ID     ,P.PACKAGE_NAME AS OBJECT_NAME     ,NULL AS SUBOBJECT_NAME     ,P.PACKAGE_ID OBJECT_ID     ,NULL AS DATA_OBJECT_ID     ,CASE WHEN TYPE = 1 THEN 'PACKAGE'           WHEN TYPE = 2 THEN 'PACKAGE BODY'           ELSE NULL END AS OBJECT_TYPE     ,CASE WHEN EXISTS                 (SELECT OBJ_ID FROM SYS.ALL_VIRTUAL_TENANT_ERROR_REAL_AGENT E                   WHERE P.TENANT_ID = E.TENANT_ID AND P.PACKAGE_ID = E.OBJ_ID AND (E.OBJ_TYPE = 3 OR E.OBJ_TYPE = 5))                THEN 'INVALID'           ELSE 'VALID' END AS STATUS     ,'N' AS TEMPORARY     ,'N' AS "GENERATED"     ,'N' AS SECONDARY     , 0 AS NAMESPACE     ,NULL AS EDITION_NAME     FROM SYS.ALL_VIRTUAL_PACKAGE_REAL_AGENT P     WHERE P.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     R.GMT_CREATE     ,R.GMT_MODIFIED     ,R.DATABASE_ID     ,R.ROUTINE_NAME AS OBJECT_NAME     ,NULL AS SUBOBJECT_NAME     ,R.ROUTINE_ID OBJECT_ID     ,NULL AS DATA_OBJECT_ID     ,CASE WHEN ROUTINE_TYPE = 1 THEN 'PROCEDURE'           WHEN ROUTINE_TYPE = 2 THEN 'FUNCTION'           ELSE NULL END AS OBJECT_TYPE     ,CASE WHEN EXISTS                 (SELECT OBJ_ID FROM SYS.ALL_VIRTUAL_TENANT_ERROR_REAL_AGENT E                   WHERE R.TENANT_ID = E.TENANT_ID AND R.ROUTINE_ID = E.OBJ_ID AND (E.OBJ_TYPE = 12 OR E.OBJ_TYPE = 9))                THEN 'INVALID'           ELSE 'VALID' END AS STATUS     ,'N' AS TEMPORARY     ,'N' AS "GENERATED"     ,'N' AS SECONDARY     , 0 AS NAMESPACE     ,NULL AS EDITION_NAME     FROM SYS.ALL_VIRTUAL_ROUTINE_REAL_AGENT R     WHERE (ROUTINE_TYPE = 1 OR ROUTINE_TYPE = 2) AND R.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     T.GMT_CREATE     ,T.GMT_MODIFIED     ,T.DATABASE_ID     ,T.TRIGGER_NAME AS OBJECT_NAME     ,NULL AS SUBOBJECT_NAME     ,T.TRIGGER_ID OBJECT_ID     ,NULL AS DATA_OBJECT_ID     ,'TRIGGER' OBJECT_TYPE     ,CASE WHEN EXISTS                 (SELECT OBJ_ID FROM SYS.ALL_VIRTUAL_TENANT_ERROR_REAL_AGENT E                   WHERE T.TENANT_ID = E.TENANT_ID AND T.TRIGGER_ID = E.OBJ_ID AND (E.OBJ_TYPE = 7))                THEN 'INVALID'           ELSE 'VALID' END AS STATUS     ,'N' AS TEMPORARY     ,'N' AS "GENERATED"     ,'N' AS SECONDARY     , 0 AS NAMESPACE     ,NULL AS EDITION_NAME     FROM SYS.ALL_VIRTUAL_TRIGGER_AGENT T     WHERE T.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     GMT_CREATE     ,GMT_MODIFIED     ,DATABASE_ID     ,SYNONYM_NAME AS OBJECT_NAME     ,NULL AS SUBOBJECT_NAME     ,SYNONYM_ID OBJECT_ID     ,NULL AS DATA_OBJECT_ID     ,'SYNONYM' AS OBJECT_TYPE     ,'VALID' AS STATUS     ,'N' AS TEMPORARY     ,'N' AS "GENERATED"     ,'N' AS SECONDARY     , 0 AS NAMESPACE     ,NULL AS EDITION_NAME     FROM SYS.ALL_VIRTUAL_SYNONYM_REAL_AGENT     WHERE TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     GMT_CREATE     ,GMT_MODIFIED     ,DATABASE_ID     ,SEQUENCE_NAME AS OBJECT_NAME     ,NULL AS SUBOBJECT_NAME     ,SEQUENCE_ID OBJECT_ID     ,NULL AS DATA_OBJECT_ID     ,'SEQUENCE' AS OBJECT_TYPE     ,'VALID' AS STATUS     ,'N' AS TEMPORARY     ,'N' AS "GENERATED"     ,'N' AS SECONDARY     , 0 AS NAMESPACE     ,NULL AS EDITION_NAME     FROM SYS.ALL_VIRTUAL_SEQUENCE_OBJECT_REAL_AGENT     WHERE TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     GMT_CREATE     ,GMT_MODIFIED     ,DATABASE_ID     ,TYPE_NAME AS OBJECT_NAME     ,NULL AS SUBOBJECT_NAME     ,TYPE_ID OBJECT_ID     ,NULL AS DATA_OBJECT_ID     ,'TYPE' AS OBJECT_TYPE     ,'VALID' AS STATUS     ,'N' AS TEMPORARY     ,'N' AS "GENERATED"     ,'N' AS SECONDARY     , 0 AS NAMESPACE     ,NULL AS EDITION_NAME     FROM SYS.ALL_VIRTUAL_TYPE_REAL_AGENT     WHERE TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     GMT_CREATE     ,GMT_MODIFIED     ,DATABASE_ID     ,OBJECT_NAME     ,NULL AS SUBOBJECT_NAME     ,OBJECT_TYPE_ID OBJECT_ID     ,NULL AS DATA_OBJECT_ID     ,'TYPE BODY' AS OBJECT_TYPE     ,'VALID' AS STATUS     ,'N' AS TEMPORARY     ,'N' AS "GENERATED"     ,'N' AS SECONDARY     , 0 AS NAMESPACE     ,NULL AS EDITION_NAME     FROM SYS.ALL_VIRTUAL_OBJECT_TYPE_AGENT     WHERE TENANT_ID = EFFECTIVE_TENANT_ID() and TYPE = 2     )A     WHERE DATABASE_ID=USERENV('SCHEMAID') )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::dba_sequences_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_DBA_SEQUENCES_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_DBA_SEQUENCES_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT        C.DATABASE_NAME AS SEQUENCE_OWNER       ,A.SEQUENCE_NAME AS SEQUENCE_NAME       ,A.MIN_VALUE AS MIN_VALUE       ,A.MAX_VALUE AS MAX_VALUE       ,A.INCREMENT_BY AS INCREMENT_BY       ,CASE A.CYCLE_FLAG WHEN 1 THEN 'Y'                          WHEN 0 THEN  'N'                          ELSE NULL END AS CYCLE_FLAG       ,CASE A.ORDER_FLAG WHEN 1 THEN 'Y'                          WHEN 0 THEN  'N'                          ELSE NULL END AS ORDER_FLAG       ,A.CACHE_SIZE AS CACHE_SIZE       ,CAST(COALESCE(B.NEXT_VALUE,A.START_WITH) AS NUMBER(38,0)) AS LAST_NUMBER     FROM        SYS.ALL_VIRTUAL_SEQUENCE_OBJECT_REAL_AGENT A     INNER JOIN        SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT C     ON A.DATABASE_ID = C.DATABASE_ID AND A.TENANT_ID = C.TENANT_ID       AND A.TENANT_ID = EFFECTIVE_TENANT_ID()       AND C.TENANT_ID = EFFECTIVE_TENANT_ID()     LEFT JOIN       SYS.ALL_VIRTUAL_SEQUENCE_VALUE_REAL_AGENT B     ON B.SEQUENCE_ID = A.SEQUENCE_ID )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::all_sequences_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_ALL_SEQUENCES_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_ALL_SEQUENCES_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT        C.DATABASE_NAME AS SEQUENCE_OWNER       ,A.SEQUENCE_NAME AS SEQUENCE_NAME       ,A.MIN_VALUE AS MIN_VALUE       ,A.MAX_VALUE AS MAX_VALUE       ,A.INCREMENT_BY AS INCREMENT_BY       ,CASE A.CYCLE_FLAG WHEN 1 THEN 'Y'                          WHEN 0 THEN  'N'                          ELSE NULL END AS CYCLE_FLAG       ,CASE A.ORDER_FLAG WHEN 1 THEN 'Y'                          WHEN 0 THEN  'N'                          ELSE NULL END AS ORDER_FLAG       ,A.CACHE_SIZE AS CACHE_SIZE       ,CAST(COALESCE(B.NEXT_VALUE,A.START_WITH) AS NUMBER(38,0)) AS LAST_NUMBER     FROM        SYS.ALL_VIRTUAL_SEQUENCE_OBJECT_REAL_AGENT A     INNER JOIN        SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT C     ON A.DATABASE_ID = C.DATABASE_ID AND A.TENANT_ID = C.TENANT_ID       AND A.TENANT_ID = EFFECTIVE_TENANT_ID()       AND C.TENANT_ID = EFFECTIVE_TENANT_ID()     AND (A.DATABASE_ID = USERENV('SCHEMAID')          OR USER_CAN_ACCESS_OBJ(2, A.SEQUENCE_ID, A.DATABASE_ID) = 1)     LEFT JOIN       SYS.ALL_VIRTUAL_SEQUENCE_VALUE_REAL_AGENT B     ON B.SEQUENCE_ID = A.SEQUENCE_ID )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::user_sequences_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_USER_SEQUENCES_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_USER_SEQUENCES_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT        A.SEQUENCE_NAME AS SEQUENCE_NAME       ,A.MIN_VALUE AS MIN_VALUE       ,A.MAX_VALUE AS MAX_VALUE       ,A.INCREMENT_BY AS INCREMENT_BY       ,CASE A.CYCLE_FLAG WHEN 1 THEN 'Y'                          WHEN 0 THEN  'N'                          ELSE NULL END AS CYCLE_FLAG       ,CASE A.ORDER_FLAG WHEN 1 THEN 'Y'                          WHEN 0 THEN  'N'                          ELSE NULL END AS ORDER_FLAG       ,A.CACHE_SIZE AS CACHE_SIZE       ,CAST(COALESCE(B.NEXT_VALUE,A.START_WITH) AS NUMBER(38,0)) AS LAST_NUMBER     FROM        SYS.ALL_VIRTUAL_SEQUENCE_OBJECT_REAL_AGENT A     LEFT JOIN       SYS.ALL_VIRTUAL_SEQUENCE_VALUE_REAL_AGENT B     ON B.SEQUENCE_ID = A.SEQUENCE_ID     WHERE       A.DATABASE_ID = USERENV('SCHEMAID') )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::dba_users_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_DBA_USERS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_DBA_USERS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT       A.DATABASE_NAME AS USERNAME,       A.DATABASE_ID AS USERID,       B.PASSWD AS PASSWORD,       CAST(NULL as VARCHAR2(30)) AS ACCOUNT_STATUS,       CAST(NULL as DATE) AS LOCK_DATE,       CAST(NULL as DATE) AS EXPIRY_DATE,       CAST(NULL as VARCHAR2(30)) AS DEFAULT_TABLESPACE,       CAST(NULL as VARCHAR2(30)) AS TEMPORARY_TABLESPACE,       CAST(A.GMT_CREATE AS DATE) AS CREATED,       CAST(NULL as VARCHAR2(30)) AS INITIAL_RSRC_CONSUMER_GROUP,       CAST(NULL as VARCHAR2(4000)) AS EXTERNAL_NAME     FROM       SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT A,       SYS.ALL_VIRTUAL_USER_REAL_AGENT B     WHERE       A.DATABASE_NAME = B.USER_NAME       AND A.TENANT_ID = B.TENANT_ID )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::all_users_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_ALL_USERS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_ALL_USERS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT       A.DATABASE_NAME AS USERNAME,       A.DATABASE_ID AS USERID,       CAST(A.GMT_CREATE AS DATE) AS CREATED     FROM       SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT A,       SYS.ALL_VIRTUAL_USER_REAL_AGENT B     WHERE       A.DATABASE_NAME = B.USER_NAME       AND A.TENANT_ID = B.TENANT_ID )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::all_synonyms_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_ALL_SYNONYMS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_ALL_SYNONYMS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT       CASE WHEN       A.DATABASE_NAME = '__public' THEN       'PUBLIC' ELSE A.DATABASE_NAME END AS OWNER,       A.SYNONYM_NAME AS SYNONYM_NAME,       CAST(CASE WHEN INSTR(A.OBJECT_NAME, '@') = 0            THEN B.DATABASE_NAME            ELSE SUBSTR(A.OBJECT_NAME, 1, INSTR(A.OBJECT_NAME, '.') -1)            END            AS VARCHAR2(128)) AS TABLE_OWNER,       CAST(CASE WHEN INSTR(A.OBJECT_NAME, '@') = 0            THEN A.OBJECT_NAME            ELSE SUBSTR(A.OBJECT_NAME, INSTR(A.OBJECT_NAME, '.') + 1, INSTR(A.OBJECT_NAME, '@') - INSTR(A.OBJECT_NAME, '.') -1)            END            AS VARCHAR2(128)) AS TABLE_NAME,       CAST(CASE WHEN INSTR(A.OBJECT_NAME, '@') = 0                 THEN NULL                 ELSE SUBSTR(A.OBJECT_NAME, INSTR(A.OBJECT_NAME, '@')+1)                 END                 AS VARCHAR2(128)) AS DB_LINK     FROM       (SELECT BB.DATABASE_NAME, AA.SYNONYM_NAME,       AA.OBJECT_NAME, AA.SYNONYM_ID       FROM       SYS.ALL_VIRTUAL_SYNONYM_REAL_AGENT AA,       SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT BB       WHERE AA.DATABASE_ID = BB.DATABASE_ID             AND AA.TENANT_ID = BB.TENANT_ID AND AA.TENANT_ID = EFFECTIVE_TENANT_ID()             AND (AA.DATABASE_ID = USERENV('SCHEMAID')                 OR USER_CAN_ACCESS_OBJ(13, AA.SYNONYM_ID, AA.DATABASE_ID) = 1)) A,       (SELECT BB.DATABASE_NAME, AA.SYNONYM_ID       FROM       SYS.ALL_VIRTUAL_SYNONYM_REAL_AGENT AA,       SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT BB       WHERE AA.OBJECT_DATABASE_ID = BB.DATABASE_ID             AND AA.TENANT_ID = BB.TENANT_ID AND AA.TENANT_ID = EFFECTIVE_TENANT_ID()             AND (AA.DATABASE_ID = USERENV('SCHEMAID')                 OR USER_CAN_ACCESS_OBJ(13, AA.SYNONYM_ID, AA.DATABASE_ID) = 1)) B     WHERE       A.SYNONYM_ID = B.SYNONYM_ID )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::user_synonyms_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_USER_SYNONYMS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_USER_SYNONYMS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT       A.SYNONYM_NAME AS SYNONYM_NAME,       CAST(CASE WHEN INSTR(A.OBJECT_NAME, '@') = 0            THEN B.DATABASE_NAME            ELSE SUBSTR(A.OBJECT_NAME, 1, INSTR(A.OBJECT_NAME, '.') -1)            END            AS VARCHAR2(128)) AS TABLE_OWNER,       CAST(CASE WHEN INSTR(A.OBJECT_NAME, '@') = 0            THEN A.OBJECT_NAME            ELSE SUBSTR(A.OBJECT_NAME, INSTR(A.OBJECT_NAME, '.') + 1, INSTR(A.OBJECT_NAME, '@') - INSTR(A.OBJECT_NAME, '.') -1)            END            AS VARCHAR2(128)) AS TABLE_NAME,       CAST(CASE WHEN INSTR(A.OBJECT_NAME, '@') = 0                 THEN NULL                 ELSE SUBSTR(A.OBJECT_NAME, INSTR(A.OBJECT_NAME, '@')+1)                 END                 AS VARCHAR2(128)) AS DB_LINK,       CAST (0 AS number) AS ORIGIN_CON_ID     FROM       (SELECT BB.DATABASE_NAME, AA.SYNONYM_NAME,       AA.OBJECT_NAME, AA.SYNONYM_ID       FROM       SYS.ALL_VIRTUAL_SYNONYM_AGENT AA,       SYS.ALL_VIRTUAL_DATABASE_AGENT BB       WHERE AA.DATABASE_ID = BB.DATABASE_ID             AND (AA.DATABASE_ID = USERENV('SCHEMAID')                 OR USER_CAN_ACCESS_OBJ(13, AA.SYNONYM_ID, AA.DATABASE_ID) = 1)) A,       (SELECT BB.DATABASE_NAME, AA.SYNONYM_ID       FROM       SYS.ALL_VIRTUAL_SYNONYM_AGENT AA,       SYS.ALL_VIRTUAL_DATABASE_AGENT BB       WHERE AA.OBJECT_DATABASE_ID = BB.DATABASE_ID            AND (AA.DATABASE_ID = USERENV('SCHEMAID')                 OR USER_CAN_ACCESS_OBJ(13, AA.SYNONYM_ID, AA.DATABASE_ID) = 1)) B     WHERE       A.SYNONYM_ID = B.SYNONYM_ID     AND       A.DATABASE_NAME = SYS_CONTEXT('USERENV','CURRENT_USER') )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::dba_ind_columns_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_DBA_IND_COLUMNS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_DBA_IND_COLUMNS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT       CAST(INDEX_OWNER AS VARCHAR2(128)) AS INDEX_OWNER,       CAST(INDEX_NAME AS VARCHAR2(128)) AS INDEX_NAME,       CAST(TABLE_OWNER AS VARCHAR2(128)) AS TABLE_OWNER,       CAST(TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,       CAST(COLUMN_NAME AS VARCHAR2(4000)) AS COLUMN_NAME,       CAST(ROWKEY_POSITION AS NUMBER) AS COLUMN_POSITION,       CASE WHEN DATA_TYPE >= 1 AND DATA_TYPE <= 16 THEN CAST(22 AS NUMBER)            WHEN DATA_TYPE = 17 THEN CAST(7 AS NUMBER)            WHEN DATA_TYPE IN (22, 23) AND F.DATA_PRECISION = 2 THEN CAST(DATA_LENGTH AS NUMBER)            WHEN DATA_TYPE IN (22, 23) AND F.DATA_PRECISION = 1 AND F.COLLATION_TYPE IN (45, 46, 224, 54, 55, 101) THEN CAST(DATA_LENGTH * 4 AS NUMBER)            WHEN DATA_TYPE IN (22, 23) AND F.DATA_PRECISION = 1 AND F.COLLATION_TYPE IN (28, 87) THEN CAST(DATA_LENGTH * 2 AS NUMBER)            WHEN DATA_TYPE = 36 THEN CAST(12 AS NUMBER)            WHEN DATA_TYPE IN (37, 38) THEN CAST(11 AS NUMBER)            WHEN DATA_TYPE = 39 THEN CAST(DATA_LENGTH AS NUMBER)            WHEN DATA_TYPE = 40 THEN CAST(5 AS NUMBER)            WHEN DATA_TYPE = 41 THEN CAST(11 AS NUMBER)         ELSE CAST(0 AS NUMBER) END AS COLUMN_LENGTH,       CASE WHEN DATA_TYPE IN (22, 23) THEN CAST(DATA_LENGTH AS NUMBER)         ELSE CAST(0 AS NUMBER) END AS CHAR_LENGTH,       CAST('ASC' AS VARCHAR2(4)) AS DESCEND       FROM         (SELECT         INDEX_OWNER,         INDEX_NAME,         TABLE_OWNER,         TABLE_NAME,         INDEX_ID,         IDX_TYPE         FROM           (SELECT           DATABASE_NAME AS INDEX_OWNER,           CASE WHEN (TABLE_TYPE = 5) THEN SUBSTR(TABLE_NAME, 7 + INSTR(SUBSTR(TABLE_NAME, 7), '_'))             ELSE (CONS_TAB.CONSTRAINT_NAME) END AS INDEX_NAME,           DATABASE_NAME AS TABLE_OWNER,           CASE WHEN (TABLE_TYPE = 3) THEN A.TABLE_ID             ELSE A.DATA_TABLE_ID END AS TABLE_ID,           A.TABLE_ID AS INDEX_ID,           TABLE_TYPE AS IDX_TYPE           FROM             SYS.ALL_VIRTUAL_TABLE_REAL_AGENT A             JOIN SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT B ON A.DATABASE_ID = B.DATABASE_ID             AND TABLE_TYPE IN (5, 3)             AND B.DATABASE_NAME != '__recyclebin'             AND A.TENANT_ID = B.TENANT_ID AND A.TENANT_ID = EFFECTIVE_TENANT_ID()             LEFT JOIN SYS.ALL_VIRTUAL_CONSTRAINT_REAL_AGENT CONS_TAB             ON (CONS_TAB.TABLE_ID = A.TABLE_ID AND A.TENANT_ID = CONS_TAB.TENANT_ID                 AND CONS_TAB.TENANT_ID = EFFECTIVE_TENANT_ID())           WHERE             NOT(             TABLE_TYPE = 3             AND CONSTRAINT_NAME IS NULL             )           ) C         JOIN SYS.ALL_VIRTUAL_TABLE_REAL_AGENT D ON C.TABLE_ID = D.TABLE_ID               AND D.TENANT_ID = EFFECTIVE_TENANT_ID()         ) E         JOIN SYS.ALL_VIRTUAL_COLUMN_REAL_AGENT F ON E.INDEX_ID = F.TABLE_ID               AND F.TENANT_ID = EFFECTIVE_TENANT_ID()       WHERE         F.ROWKEY_POSITION != 0 AND (CASE WHEN IDX_TYPE = 5 THEN INDEX_POSITION ELSE 1 END) != 0 )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::all_ind_columns_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_ALL_IND_COLUMNS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_ALL_IND_COLUMNS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT       CAST(INDEX_OWNER AS VARCHAR2(128)) AS INDEX_OWNER,       CAST(INDEX_NAME AS VARCHAR2(128)) AS INDEX_NAME,       CAST(TABLE_OWNER AS VARCHAR2(128)) AS TABLE_OWNER,       CAST(TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,       CAST(COLUMN_NAME AS VARCHAR2(4000)) AS COLUMN_NAME,       CAST(ROWKEY_POSITION AS NUMBER) AS COLUMN_POSITION,       CASE WHEN DATA_TYPE >= 1 AND DATA_TYPE <= 16 THEN CAST(22 AS NUMBER)            WHEN DATA_TYPE = 17 THEN CAST(7 AS NUMBER)            WHEN DATA_TYPE IN (22, 23) AND F.DATA_PRECISION = 2 THEN CAST(DATA_LENGTH AS NUMBER)            WHEN DATA_TYPE IN (22, 23) AND F.DATA_PRECISION = 1 AND F.COLLATION_TYPE IN (45, 46, 224, 54, 55, 101) THEN CAST(DATA_LENGTH * 4 AS NUMBER)            WHEN DATA_TYPE IN (22, 23) AND F.DATA_PRECISION = 1 AND F.COLLATION_TYPE IN (28, 87) THEN CAST(DATA_LENGTH * 2 AS NUMBER)            WHEN DATA_TYPE = 36 THEN CAST(12 AS NUMBER)            WHEN DATA_TYPE IN (37, 38) THEN CAST(11 AS NUMBER)            WHEN DATA_TYPE = 39 THEN CAST(DATA_LENGTH AS NUMBER)            WHEN DATA_TYPE = 40 THEN CAST(5 AS NUMBER)            WHEN DATA_TYPE = 41 THEN CAST(11 AS NUMBER)         ELSE CAST(0 AS NUMBER) END AS COLUMN_LENGTH,       CASE WHEN DATA_TYPE IN (22, 23) THEN CAST(DATA_LENGTH AS NUMBER)         ELSE CAST(0 AS NUMBER) END AS CHAR_LENGTH,       CAST('ASC' AS VARCHAR2(4)) AS DESCEND       FROM         (SELECT         INDEX_OWNER,         INDEX_NAME,         TABLE_OWNER,         TABLE_NAME,         INDEX_ID,         IDX_TYPE         FROM           (SELECT           DATABASE_NAME AS INDEX_OWNER,           CASE WHEN (TABLE_TYPE = 5) THEN SUBSTR(TABLE_NAME, 7 + INSTR(SUBSTR(TABLE_NAME, 7), '_'))             ELSE (CONS_TAB.CONSTRAINT_NAME) END AS INDEX_NAME,           DATABASE_NAME AS TABLE_OWNER,           CASE WHEN (TABLE_TYPE = 3) THEN A.TABLE_ID             ELSE A.DATA_TABLE_ID END AS TABLE_ID,           A.TABLE_ID AS INDEX_ID,           TABLE_TYPE AS IDX_TYPE           FROM             SYS.ALL_VIRTUAL_TABLE_REAL_AGENT A             JOIN SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT B ON A.DATABASE_ID = B.DATABASE_ID             AND TABLE_TYPE IN (5, 3)             AND B.DATABASE_NAME != '__recyclebin'             AND A.TENANT_ID = EFFECTIVE_TENANT_ID()             AND B.TENANT_ID = EFFECTIVE_TENANT_ID()             AND (A.DATABASE_ID = USERENV('SCHEMAID')                  OR USER_CAN_ACCESS_OBJ(1, DECODE(TABLE_TYPE, 3, TABLE_ID, 5, DATA_TABLE_ID), A.DATABASE_ID) = 1)             LEFT JOIN SYS.ALL_VIRTUAL_CONSTRAINT_REAL_AGENT CONS_TAB               ON (CONS_TAB.TABLE_ID = A.TABLE_ID AND CONS_TAB.TENANT_ID = EFFECTIVE_TENANT_ID())           WHERE             NOT(             TABLE_TYPE = 3             AND CONSTRAINT_NAME IS NULL             )           ) C         JOIN SYS.ALL_VIRTUAL_TABLE_REAL_AGENT D ON C.TABLE_ID = D.TABLE_ID               AND D.TENANT_ID = EFFECTIVE_TENANT_ID()         ) E         JOIN SYS.ALL_VIRTUAL_COLUMN_REAL_AGENT F ON E.INDEX_ID = F.TABLE_ID               AND F.TENANT_ID = EFFECTIVE_TENANT_ID()       WHERE         F.ROWKEY_POSITION != 0 AND (CASE WHEN IDX_TYPE = 5 THEN INDEX_POSITION ELSE 1 END) != 0 )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::user_ind_columns_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_USER_IND_COLUMNS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_USER_IND_COLUMNS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT       CAST(INDEX_NAME AS VARCHAR2(128)) AS INDEX_NAME,       CAST(TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,       CAST(COLUMN_NAME AS VARCHAR2(4000)) AS COLUMN_NAME,       CAST(ROWKEY_POSITION AS NUMBER) AS COLUMN_POSITION,       CASE WHEN DATA_TYPE >= 1 AND DATA_TYPE <= 16 THEN CAST(22 AS NUMBER)            WHEN DATA_TYPE = 17 THEN CAST(7 AS NUMBER)            WHEN DATA_TYPE IN (22, 23) AND F.DATA_PRECISION = 2 THEN CAST(DATA_LENGTH AS NUMBER)            WHEN DATA_TYPE IN (22, 23) AND F.DATA_PRECISION = 1 AND F.COLLATION_TYPE IN (45, 46, 224, 54, 55, 101) THEN CAST(DATA_LENGTH * 4 AS NUMBER)            WHEN DATA_TYPE IN (22, 23) AND F.DATA_PRECISION = 1 AND F.COLLATION_TYPE IN (28, 87) THEN CAST(DATA_LENGTH * 2 AS NUMBER)            WHEN DATA_TYPE = 36 THEN CAST(12 AS NUMBER)            WHEN DATA_TYPE IN (37, 38) THEN CAST(11 AS NUMBER)            WHEN DATA_TYPE = 39 THEN CAST(DATA_LENGTH AS NUMBER)            WHEN DATA_TYPE = 40 THEN CAST(5 AS NUMBER)            WHEN DATA_TYPE = 41 THEN CAST(11 AS NUMBER)         ELSE CAST(0 AS NUMBER) END AS COLUMN_LENGTH,       CASE WHEN DATA_TYPE IN (22, 23) THEN CAST(DATA_LENGTH AS NUMBER)         ELSE CAST(0 AS NUMBER) END AS CHAR_LENGTH,       CAST('ASC' AS VARCHAR2(4)) AS DESCEND       FROM         (SELECT         INDEX_OWNER,         INDEX_NAME,         TABLE_OWNER,         TABLE_NAME,         INDEX_ID,         IDX_TYPE         FROM           (SELECT           DATABASE_NAME AS INDEX_OWNER,           CASE WHEN (TABLE_TYPE = 5) THEN SUBSTR(TABLE_NAME, 7 + INSTR(SUBSTR(TABLE_NAME, 7), '_'))             ELSE (CONS_TAB.CONSTRAINT_NAME) END AS INDEX_NAME,           DATABASE_NAME AS TABLE_OWNER,           CASE WHEN (TABLE_TYPE = 3) THEN A.TABLE_ID             ELSE A.DATA_TABLE_ID END AS TABLE_ID,           A.TABLE_ID AS INDEX_ID,           TABLE_TYPE AS IDX_TYPE           FROM             SYS.ALL_VIRTUAL_TABLE_REAL_AGENT A             JOIN SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT B ON A.DATABASE_ID = B.DATABASE_ID             AND TABLE_TYPE IN (5, 3)             AND A.DATABASE_ID = USERENV('SCHEMAID')             AND B.DATABASE_NAME != '__recyclebin'             AND A.TENANT_ID = EFFECTIVE_TENANT_ID()             AND B.TENANT_ID = EFFECTIVE_TENANT_ID()             LEFT JOIN SYS.ALL_VIRTUAL_CONSTRAINT_REAL_AGENT CONS_TAB               ON (CONS_TAB.TABLE_ID = A.TABLE_ID AND CONS_TAB.TENANT_ID = EFFECTIVE_TENANT_ID())           WHERE             NOT(             TABLE_TYPE = 3             AND CONSTRAINT_NAME IS NULL             )           ) C         JOIN SYS.ALL_VIRTUAL_TABLE_REAL_AGENT D ON C.TABLE_ID = D.TABLE_ID               AND D.TENANT_ID = EFFECTIVE_TENANT_ID()         ) E         JOIN SYS.ALL_VIRTUAL_COLUMN_REAL_AGENT F ON E.INDEX_ID = F.TABLE_ID               AND F.TENANT_ID = EFFECTIVE_TENANT_ID()       WHERE         F.ROWKEY_POSITION != 0 AND (CASE WHEN IDX_TYPE = 5 THEN INDEX_POSITION ELSE 1 END) != 0 )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::dba_constraints_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_DBA_CONSTRAINTS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_DBA_CONSTRAINTS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT     CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS OWNER,     CAST(SUBSTR(A.TABLE_NAME, 7 + INSTR(SUBSTR(A.TABLE_NAME, 7), '_')) AS VARCHAR2(128)) AS CONSTRAINT_NAME,     CAST('U' AS VARCHAR2(1)) AS CONSTRAINT_TYPE,     CAST(B.TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,     CAST(NULL AS VARCHAR2(4000)) AS SEARCH_CONDITION,     CAST(NULL AS VARCHAR2(128)) AS R_OWNER,     CAST(NULL AS VARCHAR2(128)) AS R_CONSTRAINT_NAME,     CAST(NULL AS VARCHAR2(9)) AS DELETE_RULE,     CAST('ENABLED' AS VARCHAR2(8)) AS STATUS,     CAST('NOT DEFERRABLE' AS VARCHAR2(14)) AS DEFERRABLE,     CAST('IMMEDIATE' AS VARCHAR2(9)) AS DEFERRED,     CAST('VALIDATED' AS VARCHAR2(13)) AS VALIDATED,     CAST(NULL AS VARCHAR2(14)) AS "GENERATED",     CAST(NULL AS VARCHAR2(3)) AS BAD,     CAST(NULL AS VARCHAR2(4)) AS RELY,     CAST(NULL AS DATE) AS LAST_CHANGE,     CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS INDEX_OWNER,     CAST(SUBSTR(A.TABLE_NAME, 7 + INSTR(SUBSTR(A.TABLE_NAME, 7), '_')) AS VARCHAR2(128)) AS INDEX_NAME,     CAST(NULL AS VARCHAR2(7)) AS INVALID,     CAST(NULL AS VARCHAR2(14)) AS VIEW_RELATED     FROM SYS.ALL_VIRTUAL_TABLE_REAL_AGENT A, SYS.ALL_VIRTUAL_TABLE_REAL_AGENT B, SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT C WHERE A.DATA_TABLE_ID = B.TABLE_ID AND A.DATABASE_ID = C.DATABASE_ID       AND A.INDEX_TYPE IN (2, 4, 8) AND C.DATABASE_NAME != '__recyclebin'       AND A.TENANT_ID = EFFECTIVE_TENANT_ID()       AND B.TENANT_ID = EFFECTIVE_TENANT_ID()       AND C.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS OWNER,     CAST(A.FOREIGN_KEY_NAME AS VARCHAR2(128)) AS CONSTRAINT_NAME,     CAST('R' AS VARCHAR2(1)) AS CONSTRAINT_TYPE,     CAST(B.TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,     CAST(NULL AS VARCHAR2(4000)) AS SEARCH_CONDITION,     CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS R_OWNER,     CAST(NULL AS VARCHAR2(128)) AS R_CONSTRAINT_NAME,     CAST(CASE WHEN DELETE_ACTION = 1 THEN 'NO ACTION'          WHEN DELETE_ACTION = 2 THEN 'CASCADE'       ELSE 'SET NULL' END AS VARCHAR2(9)) AS DELETE_RULE,     CASE WHEN A.ENABLE_FLAG = 1 THEN CAST('ENABLED' AS VARCHAR2(8))          ELSE CAST('DISABLED' AS VARCHAR2(8)) END AS STATUS,     CAST('NOT DEFERRABLE' AS VARCHAR2(14)) AS DEFERRABLE,     CAST('IMMEDIATE' AS VARCHAR2(9)) AS DEFERRED,     CASE WHEN A.VALIDATE_FLAG = 1 THEN CAST('VALIDATED' AS VARCHAR2(13))          ELSE CAST('NOT VALIDATED' AS VARCHAR2(13)) END AS VALIDATED,     CAST(NULL AS VARCHAR2(14)) AS "GENERATED",     CAST(NULL AS VARCHAR2(3)) AS BAD,     CASE WHEN A.RELY_FLAG = 1 THEN CAST('RELY' AS VARCHAR2(4))          ELSE CAST(NULL AS VARCHAR2(4)) END AS RELY,     CAST(NULL AS DATE) AS LAST_CHANGE,     CAST(NULL AS VARCHAR2(128)) AS INDEX_OWNER,     CAST(NULL AS VARCHAR2(128)) AS INDEX_NAME,     CAST(NULL AS VARCHAR2(7)) AS INVALID,     CAST(NULL AS VARCHAR2(14)) AS VIEW_RELATED     FROM SYS.ALL_VIRTUAL_FOREIGN_KEY_REAL_AGENT A, SYS.ALL_VIRTUAL_TABLE_REAL_AGENT B, SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT C     WHERE A.CHILD_TABLE_ID = B.TABLE_ID AND B.DATABASE_ID = C.DATABASE_ID AND A.REF_CST_TYPE = 0 AND A.REF_CST_ID = -1       AND A.TENANT_ID = EFFECTIVE_TENANT_ID()       AND B.TENANT_ID = EFFECTIVE_TENANT_ID()       AND C.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS OWNER,     CAST(A.FOREIGN_KEY_NAME AS VARCHAR2(128)) AS CONSTRAINT_NAME,     CAST('R' AS VARCHAR2(1)) AS CONSTRAINT_TYPE,     CAST(B.TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,     CAST(NULL AS VARCHAR2(4000)) AS SEARCH_CONDITION,     CAST(E.DATABASE_NAME AS VARCHAR2(128)) AS R_OWNER,     CAST(CASE WHEN A.REF_CST_TYPE = 2 THEN SUBSTR(F.TABLE_NAME, 7 + INSTR(SUBSTR(F.TABLE_NAME, 7), '_'))          ELSE NULL END AS VARCHAR2(128)) AS R_CONSTRAINT_NAME,     CAST(CASE WHEN DELETE_ACTION = 1 THEN 'NO ACTION'          WHEN DELETE_ACTION = 2 THEN 'CASCADE'          ELSE 'SET NULL' END AS VARCHAR2(9)) AS DELETE_RULE,     CASE WHEN A.ENABLE_FLAG = 1 THEN CAST('ENABLED' AS VARCHAR2(8))          ELSE CAST('DISABLED' AS VARCHAR2(8)) END AS STATUS,     CAST('NOT DEFERRABLE' AS VARCHAR2(14)) AS DEFERRABLE,     CAST('IMMEDIATE' AS VARCHAR2(9)) AS DEFERRED,     CASE WHEN A.VALIDATE_FLAG = 1 THEN CAST('VALIDATED' AS VARCHAR2(13))          ELSE CAST('NOT VALIDATED' AS VARCHAR2(13)) END AS VALIDATED,     CAST(NULL AS VARCHAR2(14)) AS "GENERATED",     CAST(NULL AS VARCHAR2(3)) AS BAD,     CASE WHEN A.RELY_FLAG = 1 THEN CAST('RELY' AS VARCHAR2(4))          ELSE CAST(NULL AS VARCHAR2(4)) END AS RELY,     CAST(NULL AS DATE) AS LAST_CHANGE,     CAST(NULL AS VARCHAR2(128)) AS INDEX_OWNER,     CAST(NULL AS VARCHAR2(128)) AS INDEX_NAME,     CAST(NULL AS VARCHAR2(7)) AS INVALID,     CAST(NULL AS VARCHAR2(14)) AS VIEW_RELATED     FROM SYS.ALL_VIRTUAL_FOREIGN_KEY_REAL_AGENT A, SYS.ALL_VIRTUAL_TABLE_REAL_AGENT B, SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT C, SYS.ALL_VIRTUAL_TABLE_REAL_AGENT D, SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT E, SYS.ALL_VIRTUAL_TABLE_REAL_AGENT F       WHERE A.CHILD_TABLE_ID = B.TABLE_ID AND B.DATABASE_ID = C.DATABASE_ID AND A.PARENT_TABLE_ID = D.TABLE_ID AND D.DATABASE_ID = E.DATABASE_ID AND (A.REF_CST_ID = F.TABLE_ID AND A.REF_CST_TYPE = 2)       AND A.TENANT_ID = EFFECTIVE_TENANT_ID()       AND B.TENANT_ID = EFFECTIVE_TENANT_ID()       AND C.TENANT_ID = EFFECTIVE_TENANT_ID()       AND D.TENANT_ID = EFFECTIVE_TENANT_ID()       AND E.TENANT_ID = EFFECTIVE_TENANT_ID()       AND F.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS OWNER,     CAST(A.FOREIGN_KEY_NAME AS VARCHAR2(128)) AS CONSTRAINT_NAME,     CAST('R' AS VARCHAR2(1)) AS CONSTRAINT_TYPE,     CAST(B.TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,     CAST(NULL AS VARCHAR2(4000)) AS SEARCH_CONDITION,     CAST(E.DATABASE_NAME AS VARCHAR2(128)) AS R_OWNER,     CAST(CASE WHEN A.REF_CST_TYPE = 1 THEN F.CONSTRAINT_NAME         ELSE NULL END AS VARCHAR2(128)) AS R_CONSTRAINT_NAME,     CAST(CASE WHEN DELETE_ACTION = 1 THEN 'NO ACTION'          WHEN DELETE_ACTION = 2 THEN 'CASCADE'          ELSE 'SET NULL' END AS VARCHAR2(9)) AS DELETE_RULE,     CASE WHEN A.ENABLE_FLAG = 1 THEN CAST('ENABLED' AS VARCHAR2(8))          ELSE CAST('DISABLED' AS VARCHAR2(8)) END AS STATUS,     CAST('NOT DEFERRABLE' AS VARCHAR2(14)) AS DEFERRABLE,     CAST('IMMEDIATE' AS VARCHAR2(9)) AS DEFERRED,     CASE WHEN A.VALIDATE_FLAG = 1 THEN CAST('VALIDATED' AS VARCHAR2(13))          ELSE CAST('NOT VALIDATED' AS VARCHAR2(13)) END AS VALIDATED,     CAST(NULL AS VARCHAR2(14)) AS "GENERATED",     CAST(NULL AS VARCHAR2(3)) AS BAD,     CASE WHEN A.RELY_FLAG = 1 THEN CAST('RELY' AS VARCHAR2(4))          ELSE CAST(NULL AS VARCHAR2(4)) END AS RELY,     CAST(NULL AS DATE) AS LAST_CHANGE,     CAST(NULL AS VARCHAR2(128)) AS INDEX_OWNER,     CAST(NULL AS VARCHAR2(128)) AS INDEX_NAME,     CAST(NULL AS VARCHAR2(7)) AS INVALID,     CAST(NULL AS VARCHAR2(14)) AS VIEW_RELATED     FROM SYS.ALL_VIRTUAL_FOREIGN_KEY_REAL_AGENT A, SYS.ALL_VIRTUAL_TABLE_REAL_AGENT B, SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT C, SYS.ALL_VIRTUAL_TABLE_REAL_AGENT D, SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT E, SYS.ALL_VIRTUAL_CONSTRAINT_REAL_AGENT F       WHERE A.CHILD_TABLE_ID = B.TABLE_ID AND B.DATABASE_ID = C.DATABASE_ID AND A.PARENT_TABLE_ID = D.TABLE_ID AND D.DATABASE_ID = E.DATABASE_ID AND (A.PARENT_TABLE_ID = F.TABLE_ID AND A.REF_CST_TYPE = 1 AND F.CONSTRAINT_TYPE = 1 AND A.REF_CST_ID = F.CONSTRAINT_ID)       AND A.TENANT_ID = EFFECTIVE_TENANT_ID()       AND B.TENANT_ID = EFFECTIVE_TENANT_ID()       AND C.TENANT_ID = EFFECTIVE_TENANT_ID()       AND D.TENANT_ID = EFFECTIVE_TENANT_ID()       AND E.TENANT_ID = EFFECTIVE_TENANT_ID()       AND F.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT       CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS OWNER,       CAST(CONSTRAINT_NAME AS VARCHAR2(128)) AS CONSTRAINT_NAME,       CASE WHEN A.CONSTRAINT_TYPE = 1 THEN CAST('P' AS VARCHAR2(1))         ELSE CAST('C' AS VARCHAR2(1)) END AS CONSTRAINT_TYPE,       CAST(B.TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,       CASE WHEN A.CONSTRAINT_TYPE = 1 THEN CAST(NULL AS VARCHAR2(4000))         ELSE CAST(A.CHECK_EXPR AS VARCHAR2(4000)) END AS SEARCH_CONDITION,       CAST(NULL AS VARCHAR2(128)) AS R_OWNER,       CAST(NULL AS VARCHAR2(128)) AS R_CONSTRAINT_NAME,       CAST(NULL AS VARCHAR2(9)) AS DELETE_RULE,       CASE WHEN A.ENABLE_FLAG = 1 THEN CAST('ENABLED' AS VARCHAR2(8))         ELSE CAST('DISABLED' AS VARCHAR2(8)) END AS STATUS,       CAST('NOT DEFERRABLE' AS VARCHAR2(14)) AS DEFERRABLE,       CAST('IMMEDIATE' AS VARCHAR2(9)) AS DEFERRED,       CASE WHEN A.VALIDATE_FLAG = 1 THEN CAST('VALIDATED' AS VARCHAR2(13))         ELSE CAST('NOT VALIDATED' AS VARCHAR2(13)) END AS VALIDATED,       CAST(NULL AS VARCHAR2(14)) AS "GENERATED",       CAST(NULL AS VARCHAR2(3)) AS BAD,       CASE WHEN A.RELY_FLAG = 1 THEN CAST('RELY' AS VARCHAR2(4))         ELSE CAST(NULL AS VARCHAR2(4)) END AS RELY,       CAST(NULL AS DATE) AS LAST_CHANGE,       CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS INDEX_OWNER,       CASE WHEN A.CONSTRAINT_TYPE = 1 THEN CAST(A.CONSTRAINT_NAME AS VARCHAR2(128))         ELSE CAST(NULL AS VARCHAR2(128)) END AS INDEX_NAME,       CAST(NULL AS VARCHAR2(7)) AS INVALID,       CAST(NULL AS VARCHAR2(14)) AS VIEW_RELATED     FROM SYS.ALL_VIRTUAL_CONSTRAINT_REAL_AGENT A, SYS.ALL_VIRTUAL_TABLE_REAL_AGENT B, SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT C     WHERE A.TABLE_ID = B.TABLE_ID AND B.DATABASE_ID = C.DATABASE_ID AND C.DATABASE_NAME != '__recyclebin'     AND A.TENANT_ID = EFFECTIVE_TENANT_ID()     AND B.TENANT_ID = EFFECTIVE_TENANT_ID()     AND C.TENANT_ID = EFFECTIVE_TENANT_ID() )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::all_constraints_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_ALL_CONSTRAINTS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_ALL_CONSTRAINTS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT     CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS OWNER,     CAST(SUBSTR(A.TABLE_NAME, 7 + INSTR(SUBSTR(A.TABLE_NAME, 7), '_')) AS VARCHAR2(128)) AS CONSTRAINT_NAME,     CAST('U' AS VARCHAR2(1)) AS CONSTRAINT_TYPE,     CAST(B.TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,     CAST(NULL AS VARCHAR2(4000)) AS SEARCH_CONDITION,     CAST(NULL AS VARCHAR2(128)) AS R_OWNER,     CAST(NULL AS VARCHAR2(128)) AS R_CONSTRAINT_NAME,     CAST(NULL AS VARCHAR2(9)) AS DELETE_RULE,     CAST('ENABLED' AS VARCHAR2(8)) AS STATUS,     CAST('NOT DEFERRABLE' AS VARCHAR2(14)) AS DEFERRABLE,     CAST('IMMEDIATE' AS VARCHAR2(9)) AS DEFERRED,     CAST('VALIDATED' AS VARCHAR2(13)) AS VALIDATED,     CAST(NULL AS VARCHAR2(14)) AS "GENERATED",     CAST(NULL AS VARCHAR2(3)) AS BAD,     CAST(NULL AS VARCHAR2(4)) AS RELY,     CAST(NULL AS DATE) AS LAST_CHANGE,     CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS INDEX_OWNER,     CAST(SUBSTR(A.TABLE_NAME, 7 + INSTR(SUBSTR(A.TABLE_NAME, 7), '_')) AS VARCHAR2(128)) AS INDEX_NAME,     CAST(NULL AS VARCHAR2(7)) AS INVALID,     CAST(NULL AS VARCHAR2(14)) AS VIEW_RELATED     FROM SYS.ALL_VIRTUAL_TABLE_REAL_AGENT A, SYS.ALL_VIRTUAL_TABLE_REAL_AGENT B, SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT C     WHERE A.DATA_TABLE_ID = B.TABLE_ID       AND A.DATABASE_ID = C.DATABASE_ID       AND (A.DATABASE_ID = USERENV('SCHEMAID')           OR USER_CAN_ACCESS_OBJ(1, A.DATA_TABLE_ID, A.DATABASE_ID) = 1)       AND A.INDEX_TYPE IN (2, 4, 8) AND C.DATABASE_NAME != '__recyclebin'       AND A.TENANT_ID = EFFECTIVE_TENANT_ID()       AND B.TENANT_ID = EFFECTIVE_TENANT_ID()       AND C.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS OWNER,     CAST(A.FOREIGN_KEY_NAME AS VARCHAR2(128)) AS CONSTRAINT_NAME,     CAST('R' AS VARCHAR2(1)) AS CONSTRAINT_TYPE,     CAST(B.TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,     CAST(NULL AS VARCHAR2(4000)) AS SEARCH_CONDITION,     CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS R_OWNER,     CAST(NULL AS VARCHAR2(128)) AS R_CONSTRAINT_NAME,     CAST(CASE WHEN DELETE_ACTION = 1 THEN 'NO ACTION'          WHEN DELETE_ACTION = 2 THEN 'CASCADE'       ELSE 'SET NULL' END AS VARCHAR2(9)) AS DELETE_RULE,     CASE WHEN A.ENABLE_FLAG = 1 THEN CAST('ENABLED' AS VARCHAR2(8))          ELSE CAST('DISABLED' AS VARCHAR2(8)) END AS STATUS,     CAST('NOT DEFERRABLE' AS VARCHAR2(14)) AS DEFERRABLE,     CAST('IMMEDIATE' AS VARCHAR2(9)) AS DEFERRED,     CASE WHEN A.VALIDATE_FLAG = 1 THEN CAST('VALIDATED' AS VARCHAR2(13))          ELSE CAST('NOT VALIDATED' AS VARCHAR2(13)) END AS VALIDATED,     CAST(NULL AS VARCHAR2(14)) AS "GENERATED",     CAST(NULL AS VARCHAR2(3)) AS BAD,     CASE WHEN A.RELY_FLAG = 1 THEN CAST('RELY' AS VARCHAR2(4))          ELSE CAST(NULL AS VARCHAR2(4)) END AS RELY,     CAST(NULL AS DATE) AS LAST_CHANGE,     CAST(NULL AS VARCHAR2(128)) AS INDEX_OWNER,     CAST(NULL AS VARCHAR2(128)) AS INDEX_NAME,     CAST(NULL AS VARCHAR2(7)) AS INVALID,     CAST(NULL AS VARCHAR2(14)) AS VIEW_RELATED     FROM SYS.ALL_VIRTUAL_FOREIGN_KEY_REAL_AGENT A, SYS.ALL_VIRTUAL_TABLE_REAL_AGENT B, SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT C     WHERE A.CHILD_TABLE_ID = B.TABLE_ID AND B.DATABASE_ID = C.DATABASE_ID AND A.REF_CST_TYPE = 0 AND A.REF_CST_ID = -1         AND A.TENANT_ID = EFFECTIVE_TENANT_ID()         AND B.TENANT_ID = EFFECTIVE_TENANT_ID()         AND C.TENANT_ID = EFFECTIVE_TENANT_ID()         AND (B.DATABASE_ID = USERENV('SCHEMAID')              OR USER_CAN_ACCESS_OBJ(1, B.TABLE_ID, B.DATABASE_ID) = 1)     UNION ALL     SELECT     CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS OWNER,     CAST(A.FOREIGN_KEY_NAME AS VARCHAR2(128)) AS CONSTRAINT_NAME,     CAST('R' AS VARCHAR2(1)) AS CONSTRAINT_TYPE,     CAST(B.TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,     CAST(NULL AS VARCHAR2(4000)) AS SEARCH_CONDITION,     CAST(E.DATABASE_NAME AS VARCHAR2(128)) AS R_OWNER,     CAST(CASE WHEN A.REF_CST_TYPE = 2 THEN SUBSTR(F.TABLE_NAME, 7 + INSTR(SUBSTR(F.TABLE_NAME, 7), '_'))          ELSE NULL END AS VARCHAR2(128)) AS R_CONSTRAINT_NAME,     CAST(CASE WHEN DELETE_ACTION = 1 THEN 'NO ACTION'          WHEN DELETE_ACTION = 2 THEN 'CASCADE'          ELSE 'SET NULL' END AS VARCHAR2(9)) AS DELETE_RULE,     CASE WHEN A.ENABLE_FLAG = 1 THEN CAST('ENABLED' AS VARCHAR2(8))          ELSE CAST('DISABLED' AS VARCHAR2(8)) END AS STATUS,     CAST('NOT DEFERRABLE' AS VARCHAR2(14)) AS DEFERRABLE,     CAST('IMMEDIATE' AS VARCHAR2(9)) AS DEFERRED,     CASE WHEN A.VALIDATE_FLAG = 1 THEN CAST('VALIDATED' AS VARCHAR2(13))          ELSE CAST('NOT VALIDATED' AS VARCHAR2(13)) END AS VALIDATED,     CAST(NULL AS VARCHAR2(14)) AS "GENERATED",     CAST(NULL AS VARCHAR2(3)) AS BAD,     CASE WHEN A.RELY_FLAG = 1 THEN CAST('RELY' AS VARCHAR2(4))          ELSE CAST(NULL AS VARCHAR2(4)) END AS RELY,     CAST(NULL AS DATE) AS LAST_CHANGE,     CAST(NULL AS VARCHAR2(128)) AS INDEX_OWNER,     CAST(NULL AS VARCHAR2(128)) AS INDEX_NAME,     CAST(NULL AS VARCHAR2(7)) AS INVALID,     CAST(NULL AS VARCHAR2(14)) AS VIEW_RELATED     FROM SYS.ALL_VIRTUAL_FOREIGN_KEY_REAL_AGENT A, SYS.ALL_VIRTUAL_TABLE_REAL_AGENT B, SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT C, SYS.ALL_VIRTUAL_TABLE_REAL_AGENT D, SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT E, SYS.ALL_VIRTUAL_TABLE_REAL_AGENT F       WHERE A.CHILD_TABLE_ID = B.TABLE_ID         AND B.DATABASE_ID = C.DATABASE_ID         AND A.PARENT_TABLE_ID = D.TABLE_ID         AND D.DATABASE_ID = E.DATABASE_ID         AND (D.DATABASE_ID = USERENV('SCHEMAID')              OR USER_CAN_ACCESS_OBJ(1, D.TABLE_ID, D.DATABASE_ID) = 1)         AND (A.REF_CST_ID = F.TABLE_ID AND A.REF_CST_TYPE = 2)         AND A.TENANT_ID = EFFECTIVE_TENANT_ID()         AND B.TENANT_ID = EFFECTIVE_TENANT_ID()         AND C.TENANT_ID = EFFECTIVE_TENANT_ID()         AND D.TENANT_ID = EFFECTIVE_TENANT_ID()         AND E.TENANT_ID = EFFECTIVE_TENANT_ID()         AND F.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS OWNER,     CAST(A.FOREIGN_KEY_NAME AS VARCHAR2(128)) AS CONSTRAINT_NAME,     CAST('R' AS VARCHAR2(1)) AS CONSTRAINT_TYPE,     CAST(B.TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,     CAST(NULL AS VARCHAR2(4000)) AS SEARCH_CONDITION,     CAST(E.DATABASE_NAME AS VARCHAR2(128)) AS R_OWNER,     CAST(CASE WHEN A.REF_CST_TYPE = 1 THEN F.CONSTRAINT_NAME         ELSE NULL END AS VARCHAR2(128)) AS R_CONSTRAINT_NAME,     CAST(CASE WHEN DELETE_ACTION = 1 THEN 'NO ACTION'          WHEN DELETE_ACTION = 2 THEN 'CASCADE'          ELSE 'SET NULL' END AS VARCHAR2(9)) AS DELETE_RULE,     CASE WHEN A.ENABLE_FLAG = 1 THEN CAST('ENABLED' AS VARCHAR2(8))          ELSE CAST('DISABLED' AS VARCHAR2(8)) END AS STATUS,     CAST('NOT DEFERRABLE' AS VARCHAR2(14)) AS DEFERRABLE,     CAST('IMMEDIATE' AS VARCHAR2(9)) AS DEFERRED,     CASE WHEN A.VALIDATE_FLAG = 1 THEN CAST('VALIDATED' AS VARCHAR2(13))          ELSE CAST('NOT VALIDATED' AS VARCHAR2(13)) END AS VALIDATED,     CAST(NULL AS VARCHAR2(14)) AS "GENERATED",     CAST(NULL AS VARCHAR2(3)) AS BAD,     CASE WHEN A.RELY_FLAG = 1 THEN CAST('RELY' AS VARCHAR2(4))          ELSE CAST(NULL AS VARCHAR2(4)) END AS RELY,     CAST(NULL AS DATE) AS LAST_CHANGE,     CAST(NULL AS VARCHAR2(128)) AS INDEX_OWNER,     CAST(NULL AS VARCHAR2(128)) AS INDEX_NAME,     CAST(NULL AS VARCHAR2(7)) AS INVALID,     CAST(NULL AS VARCHAR2(14)) AS VIEW_RELATED     FROM SYS.ALL_VIRTUAL_FOREIGN_KEY_REAL_AGENT A, SYS.ALL_VIRTUAL_TABLE_REAL_AGENT B, SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT C, SYS.ALL_VIRTUAL_TABLE_REAL_AGENT D, SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT E, SYS.ALL_VIRTUAL_CONSTRAINT_REAL_AGENT F       WHERE A.CHILD_TABLE_ID = B.TABLE_ID         AND B.DATABASE_ID = C.DATABASE_ID         AND A.PARENT_TABLE_ID = D.TABLE_ID         AND D.DATABASE_ID = E.DATABASE_ID         AND (D.DATABASE_ID = USERENV('SCHEMAID')              OR USER_CAN_ACCESS_OBJ(1, D.TABLE_ID, D.DATABASE_ID) = 1)         AND (A.PARENT_TABLE_ID = F.TABLE_ID              AND A.REF_CST_TYPE = 1              AND F.CONSTRAINT_TYPE = 1              AND A.REF_CST_ID = F.CONSTRAINT_ID)         AND A.TENANT_ID = EFFECTIVE_TENANT_ID()         AND B.TENANT_ID = EFFECTIVE_TENANT_ID()         AND C.TENANT_ID = EFFECTIVE_TENANT_ID()         AND D.TENANT_ID = EFFECTIVE_TENANT_ID()         AND E.TENANT_ID = EFFECTIVE_TENANT_ID()         AND F.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT       CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS OWNER,       CAST(CONSTRAINT_NAME AS VARCHAR2(128)) AS CONSTRAINT_NAME,       CASE WHEN A.CONSTRAINT_TYPE = 1 THEN CAST('P' AS VARCHAR2(1))         ELSE CAST('C' AS VARCHAR2(1)) END AS CONSTRAINT_TYPE,       CAST(B.TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,       CASE WHEN A.CONSTRAINT_TYPE = 1 THEN CAST(NULL AS VARCHAR2(4000))         ELSE CAST(A.CHECK_EXPR AS VARCHAR2(4000)) END AS SEARCH_CONDITION,       CAST(NULL AS VARCHAR2(128)) AS R_OWNER,       CAST(NULL AS VARCHAR2(128)) AS R_CONSTRAINT_NAME,       CAST(NULL AS VARCHAR2(9)) AS DELETE_RULE,       CASE WHEN A.ENABLE_FLAG = 1 THEN CAST('ENABLED' AS VARCHAR2(8))         ELSE CAST('DISABLED' AS VARCHAR2(8)) END AS STATUS,       CAST('NOT DEFERRABLE' AS VARCHAR2(14)) AS DEFERRABLE,       CAST('IMMEDIATE' AS VARCHAR2(9)) AS DEFERRED,       CASE WHEN A.VALIDATE_FLAG = 1 THEN CAST('VALIDATED' AS VARCHAR2(13))         ELSE CAST('NOT VALIDATED' AS VARCHAR2(13)) END AS VALIDATED,       CAST(NULL AS VARCHAR2(14)) AS "GENERATED",       CAST(NULL AS VARCHAR2(3)) AS BAD,       CASE WHEN A.RELY_FLAG = 1 THEN CAST('RELY' AS VARCHAR2(4))         ELSE CAST(NULL AS VARCHAR2(4)) END AS RELY,       CAST(NULL AS DATE) AS LAST_CHANGE,       CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS INDEX_OWNER,       CASE WHEN A.CONSTRAINT_TYPE = 1 THEN CAST(A.CONSTRAINT_NAME AS VARCHAR2(128))         ELSE CAST(NULL AS VARCHAR2(128)) END AS INDEX_NAME,       CAST(NULL AS VARCHAR2(7)) AS INVALID,       CAST(NULL AS VARCHAR2(14)) AS VIEW_RELATED     FROM SYS.ALL_VIRTUAL_CONSTRAINT_REAL_AGENT A, SYS.ALL_VIRTUAL_TABLE_REAL_AGENT B, SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT C     WHERE A.TABLE_ID = B.TABLE_ID       AND B.DATABASE_ID = C.DATABASE_ID       AND (B.DATABASE_ID = USERENV('SCHEMAID')              OR USER_CAN_ACCESS_OBJ(1, B.TABLE_ID, B.DATABASE_ID) = 1)       AND C.DATABASE_NAME != '__recyclebin'       AND A.TENANT_ID = EFFECTIVE_TENANT_ID()       AND B.TENANT_ID = EFFECTIVE_TENANT_ID()       AND C.TENANT_ID = EFFECTIVE_TENANT_ID() )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::user_constraints_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_USER_CONSTRAINTS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_USER_CONSTRAINTS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT     CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS OWNER,     CAST(SUBSTR(A.TABLE_NAME, 7 + INSTR(SUBSTR(A.TABLE_NAME, 7), '_')) AS VARCHAR2(128)) AS CONSTRAINT_NAME,     CAST('U' AS VARCHAR2(1)) AS CONSTRAINT_TYPE,     CAST(B.TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,     CAST(NULL AS VARCHAR2(4000)) AS SEARCH_CONDITION,     CAST(NULL AS VARCHAR2(128)) AS R_OWNER,     CAST(NULL AS VARCHAR2(128)) AS R_CONSTRAINT_NAME,     CAST(NULL AS VARCHAR2(9)) AS DELETE_RULE,     CAST('ENABLED' AS VARCHAR2(8)) AS STATUS,     CAST('NOT DEFERRABLE' AS VARCHAR2(14)) AS DEFERRABLE,     CAST('IMMEDIATE' AS VARCHAR2(9)) AS DEFERRED,     CAST('VALIDATED' AS VARCHAR2(13)) AS VALIDATED,     CAST(NULL AS VARCHAR2(14)) AS "GENERATED",     CAST(NULL AS VARCHAR2(3)) AS BAD,     CAST(NULL AS VARCHAR2(4)) AS RELY,     CAST(NULL AS DATE) AS LAST_CHANGE,     CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS INDEX_OWNER,     CAST(SUBSTR(A.TABLE_NAME, 7 + INSTR(SUBSTR(A.TABLE_NAME, 7), '_')) AS VARCHAR2(128)) AS INDEX_NAME,     CAST(NULL AS VARCHAR2(7)) AS INVALID,     CAST(NULL AS VARCHAR2(14)) AS VIEW_RELATED     FROM SYS.ALL_VIRTUAL_TABLE_REAL_AGENT A, SYS.ALL_VIRTUAL_TABLE_REAL_AGENT B, SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT C WHERE A.DATA_TABLE_ID = B.TABLE_ID AND A.DATABASE_ID = C.DATABASE_ID       AND A.DATABASE_ID = USERENV('SCHEMAID') AND A.INDEX_TYPE IN (2, 4, 8)       AND A.TENANT_ID = EFFECTIVE_TENANT_ID()       AND B.TENANT_ID = EFFECTIVE_TENANT_ID()       AND C.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS OWNER,     CAST(A.FOREIGN_KEY_NAME AS VARCHAR2(128)) AS CONSTRAINT_NAME,     CAST('R' AS VARCHAR2(1)) AS CONSTRAINT_TYPE,     CAST(B.TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,     CAST(NULL AS VARCHAR2(4000)) AS SEARCH_CONDITION,     CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS R_OWNER,     CAST(NULL AS VARCHAR2(128)) AS R_CONSTRAINT_NAME,     CAST(CASE WHEN DELETE_ACTION = 1 THEN 'NO ACTION'          WHEN DELETE_ACTION = 2 THEN 'CASCADE'       ELSE 'SET NULL' END AS VARCHAR2(9)) AS DELETE_RULE,     CASE WHEN A.ENABLE_FLAG = 1 THEN CAST('ENABLED' AS VARCHAR2(8))          ELSE CAST('DISABLED' AS VARCHAR2(8)) END AS STATUS,     CAST('NOT DEFERRABLE' AS VARCHAR2(14)) AS DEFERRABLE,     CAST('IMMEDIATE' AS VARCHAR2(9)) AS DEFERRED,     CASE WHEN A.VALIDATE_FLAG = 1 THEN CAST('VALIDATED' AS VARCHAR2(13))          ELSE CAST('NOT VALIDATED' AS VARCHAR2(13)) END AS VALIDATED,     CAST(NULL AS VARCHAR2(14)) AS "GENERATED",     CAST(NULL AS VARCHAR2(3)) AS BAD,     CAST(NULL AS VARCHAR2(4)) AS RELY,     CAST(NULL AS DATE) AS LAST_CHANGE,     CAST(NULL AS VARCHAR2(128)) AS INDEX_OWNER,     CAST(NULL AS VARCHAR2(128)) AS INDEX_NAME,     CAST(NULL AS VARCHAR2(7)) AS INVALID,     CAST(NULL AS VARCHAR2(14)) AS VIEW_RELATED     FROM SYS.ALL_VIRTUAL_FOREIGN_KEY_REAL_AGENT A, SYS.ALL_VIRTUAL_TABLE_REAL_AGENT B, SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT C       WHERE A.CHILD_TABLE_ID = B.TABLE_ID AND B.DATABASE_ID = C.DATABASE_ID AND A.REF_CST_TYPE = 0 AND A.REF_CST_ID = -1 AND B.DATABASE_ID = USERENV('SCHEMAID')         AND A.TENANT_ID = EFFECTIVE_TENANT_ID()         AND B.TENANT_ID = EFFECTIVE_TENANT_ID()         AND C.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS OWNER,     CAST(A.FOREIGN_KEY_NAME AS VARCHAR2(128)) AS CONSTRAINT_NAME,     CAST('R' AS VARCHAR2(1)) AS CONSTRAINT_TYPE,     CAST(B.TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,     CAST(NULL AS VARCHAR2(4000)) AS SEARCH_CONDITION,     CAST(E.DATABASE_NAME AS VARCHAR2(128)) AS R_OWNER,     CAST(CASE WHEN A.REF_CST_TYPE = 2 THEN SUBSTR(F.TABLE_NAME, 7 + INSTR(SUBSTR(F.TABLE_NAME, 7), '_'))          ELSE NULL END AS VARCHAR2(128)) AS R_CONSTRAINT_NAME,     CAST(CASE WHEN DELETE_ACTION = 1 THEN 'NO ACTION'          WHEN DELETE_ACTION = 2 THEN 'CASCADE'          ELSE 'SET NULL' END AS VARCHAR2(9)) AS DELETE_RULE,     CASE WHEN A.ENABLE_FLAG = 1 THEN CAST('ENABLED' AS VARCHAR2(8))          ELSE CAST('DISABLED' AS VARCHAR2(8)) END AS STATUS,     CAST('NOT DEFERRABLE' AS VARCHAR2(14)) AS DEFERRABLE,     CAST('IMMEDIATE' AS VARCHAR2(9)) AS DEFERRED,     CASE WHEN A.VALIDATE_FLAG = 1 THEN CAST('VALIDATED' AS VARCHAR2(13))          ELSE CAST('NOT VALIDATED' AS VARCHAR2(13)) END AS VALIDATED,     CAST(NULL AS VARCHAR2(14)) AS "GENERATED",     CAST(NULL AS VARCHAR2(3)) AS BAD,     CASE WHEN A.RELY_FLAG = 1 THEN CAST('RELY' AS VARCHAR2(4))          ELSE CAST(NULL AS VARCHAR2(4)) END AS RELY,     CAST(NULL AS DATE) AS LAST_CHANGE,     CAST(NULL AS VARCHAR2(128)) AS INDEX_OWNER,     CAST(NULL AS VARCHAR2(128)) AS INDEX_NAME,     CAST(NULL AS VARCHAR2(7)) AS INVALID,     CAST(NULL AS VARCHAR2(14)) AS VIEW_RELATED     FROM SYS.ALL_VIRTUAL_FOREIGN_KEY_REAL_AGENT A, SYS.ALL_VIRTUAL_TABLE_REAL_AGENT B, SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT C, SYS.ALL_VIRTUAL_TABLE_REAL_AGENT D, SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT E, SYS.ALL_VIRTUAL_TABLE_REAL_AGENT F       WHERE A.CHILD_TABLE_ID = B.TABLE_ID AND B.DATABASE_ID = C.DATABASE_ID AND A.PARENT_TABLE_ID = D.TABLE_ID AND D.DATABASE_ID = E.DATABASE_ID AND (A.REF_CST_ID = F.TABLE_ID AND A.REF_CST_TYPE = 2) AND B.DATABASE_ID = USERENV('SCHEMAID')       AND A.TENANT_ID = EFFECTIVE_TENANT_ID()       AND B.TENANT_ID = EFFECTIVE_TENANT_ID()       AND C.TENANT_ID = EFFECTIVE_TENANT_ID()       AND D.TENANT_ID = EFFECTIVE_TENANT_ID()       AND E.TENANT_ID = EFFECTIVE_TENANT_ID()       AND F.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT     CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS OWNER,     CAST(A.FOREIGN_KEY_NAME AS VARCHAR2(128)) AS CONSTRAINT_NAME,     CAST('R' AS VARCHAR2(1)) AS CONSTRAINT_TYPE,     CAST(B.TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,     CAST(NULL AS VARCHAR2(4000)) AS SEARCH_CONDITION,     CAST(E.DATABASE_NAME AS VARCHAR2(128)) AS R_OWNER,     CAST(CASE WHEN A.REF_CST_TYPE = 1 THEN F.CONSTRAINT_NAME         ELSE NULL END AS VARCHAR2(128)) AS R_CONSTRAINT_NAME,     CAST(CASE WHEN DELETE_ACTION = 1 THEN 'NO ACTION'          WHEN DELETE_ACTION = 2 THEN 'CASCADE'          ELSE 'SET NULL' END AS VARCHAR2(9)) AS DELETE_RULE,     CASE WHEN A.ENABLE_FLAG = 1 THEN CAST('ENABLED' AS VARCHAR2(8))          ELSE CAST('DISABLED' AS VARCHAR2(8)) END AS STATUS,     CAST('NOT DEFERRABLE' AS VARCHAR2(14)) AS DEFERRABLE,     CAST('IMMEDIATE' AS VARCHAR2(9)) AS DEFERRED,     CASE WHEN A.VALIDATE_FLAG = 1 THEN CAST('VALIDATED' AS VARCHAR2(13))          ELSE CAST('NOT VALIDATED' AS VARCHAR2(13)) END AS VALIDATED,     CAST(NULL AS VARCHAR2(14)) AS "GENERATED",     CAST(NULL AS VARCHAR2(3)) AS BAD,     CASE WHEN A.RELY_FLAG = 1 THEN CAST('RELY' AS VARCHAR2(4))          ELSE CAST(NULL AS VARCHAR2(4)) END AS RELY,     CAST(NULL AS DATE) AS LAST_CHANGE,     CAST(NULL AS VARCHAR2(128)) AS INDEX_OWNER,     CAST(NULL AS VARCHAR2(128)) AS INDEX_NAME,     CAST(NULL AS VARCHAR2(7)) AS INVALID,     CAST(NULL AS VARCHAR2(14)) AS VIEW_RELATED     FROM SYS.ALL_VIRTUAL_FOREIGN_KEY_REAL_AGENT A, SYS.ALL_VIRTUAL_TABLE_REAL_AGENT B, SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT C, SYS.ALL_VIRTUAL_TABLE_REAL_AGENT D, SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT E, SYS.ALL_VIRTUAL_CONSTRAINT_REAL_AGENT F       WHERE A.CHILD_TABLE_ID = B.TABLE_ID AND B.DATABASE_ID = C.DATABASE_ID AND A.PARENT_TABLE_ID = D.TABLE_ID AND D.DATABASE_ID = E.DATABASE_ID AND (A.PARENT_TABLE_ID = F.TABLE_ID AND A.REF_CST_TYPE = 1 AND F.CONSTRAINT_TYPE = 1 AND A.REF_CST_ID = F.CONSTRAINT_ID) AND B.DATABASE_ID = USERENV('SCHEMAID')       AND A.TENANT_ID = EFFECTIVE_TENANT_ID()       AND B.TENANT_ID = EFFECTIVE_TENANT_ID()       AND C.TENANT_ID = EFFECTIVE_TENANT_ID()       AND D.TENANT_ID = EFFECTIVE_TENANT_ID()       AND E.TENANT_ID = EFFECTIVE_TENANT_ID()       AND F.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT       CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS OWNER,       CAST(CONSTRAINT_NAME AS VARCHAR2(128)) AS CONSTRAINT_NAME,       CASE WHEN A.CONSTRAINT_TYPE = 1 THEN CAST('P' AS VARCHAR2(1))         ELSE CAST('C' AS VARCHAR2(1)) END AS CONSTRAINT_TYPE,       CAST(B.TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,       CASE WHEN A.CONSTRAINT_TYPE = 1 THEN CAST(NULL AS VARCHAR2(4000))         ELSE CAST(A.CHECK_EXPR AS VARCHAR2(4000)) END AS SEARCH_CONDITION,       CAST(NULL AS VARCHAR2(128)) AS R_OWNER,       CAST(NULL AS VARCHAR2(128)) AS R_CONSTRAINT_NAME,       CAST(NULL AS VARCHAR2(9)) AS DELETE_RULE,       CASE WHEN A.ENABLE_FLAG = 1 THEN CAST('ENABLED' AS VARCHAR2(8))         ELSE CAST('DISABLED' AS VARCHAR2(8)) END AS STATUS,       CAST('NOT DEFERRABLE' AS VARCHAR2(14)) AS DEFERRABLE,       CAST('IMMEDIATE' AS VARCHAR2(9)) AS DEFERRED,       CASE WHEN A.VALIDATE_FLAG = 1 THEN CAST('VALIDATED' AS VARCHAR2(13))         ELSE CAST('NOT VALIDATED' AS VARCHAR2(13)) END AS VALIDATED,       CAST(NULL AS VARCHAR2(14)) AS "GENERATED",       CAST(NULL AS VARCHAR2(3)) AS BAD,       CASE WHEN A.RELY_FLAG = 1 THEN CAST('RELY' AS VARCHAR2(4))         ELSE CAST(NULL AS VARCHAR2(4)) END AS RELY,       CAST(NULL AS DATE) AS LAST_CHANGE,       CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS INDEX_OWNER,       CASE WHEN A.CONSTRAINT_TYPE = 1 THEN CAST(A.CONSTRAINT_NAME AS VARCHAR2(128))         ELSE CAST(NULL AS VARCHAR2(128)) END AS INDEX_NAME,       CAST(NULL AS VARCHAR2(7)) AS INVALID,       CAST(NULL AS VARCHAR2(14)) AS VIEW_RELATED     FROM SYS.ALL_VIRTUAL_CONSTRAINT_REAL_AGENT A, SYS.ALL_VIRTUAL_TABLE_REAL_AGENT B, SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT C     WHERE C.DATABASE_ID = USERENV('SCHEMAID') AND A.TABLE_ID = B.TABLE_ID AND B.DATABASE_ID = C.DATABASE_ID AND C.DATABASE_NAME != '__recyclebin'     AND A.TENANT_ID = EFFECTIVE_TENANT_ID()     AND B.TENANT_ID = EFFECTIVE_TENANT_ID()     AND C.TENANT_ID = EFFECTIVE_TENANT_ID() )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::all_tab_cols_v_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_ALL_TAB_COLS_V_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_ALL_TAB_COLS_V_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT   cast(db.database_name as VARCHAR2(128)) as OWNER,   cast(t.table_name as VARCHAR2(128)) as  TABLE_NAME,   cast(c.column_name as VARCHAR2(128)) as  COLUMN_NAME,   cast(decode(c.data_type,         0, 'NULL',          1, 'NUMBER',         2, 'NUMBER',         3, 'NUMBER',         4, 'NUMBER',         5, 'NUMBER',          6, 'NUMBER',         7, 'NUMBER',         8, 'NUMBER',         9, 'NUMBER',         10, 'NUMBER',          11, 'BINARY_FLOAT',         12, 'BINARY_DOUBLE',          13, 'NUMBER',         14, 'NUMBER',          15, 'NUMBER',         16, 'NUMBER',          17, 'DATE',         18, 'TIMESTAMP',         19, 'DATE',         20, 'TIME',         21, 'YEAR',          22, 'VARCHAR2',         23, 'CHAR',         24, 'HEX_STRING',          25, 'EXT',         26, 'UNKNOWN',          27, 'TINYTEXT',         28, 'TEXT',         29, 'MEDIUMTEXT',         30, decode(c.collation_type, 63, 'BLOB', 'CLOB'),         31, 'BIT',         32, 'ENUM',         33, 'SET',         34, 'ENUM_INNER',         35, 'SET_INNER',         36, concat('TIMESTAMP(', concat(c.data_scale, ') WITH TIME ZONE')),         37, concat('TIMESTAMP(', concat(c.data_scale, ') WITH LOCAL TIME ZONE')),         38, concat('TIMESTAMP(', concat(c.data_scale, ')')),         39, 'RAW',         40, concat('INTERVAL YEAR(', concat(c.data_scale, ') TO MONTH')),         41, concat('INTERVAL DAY(', concat(trunc(c.data_scale/10), concat(') TO SECOND(', concat(mod(c.data_scale, 10), ')')))),         42, 'FLOAT',         43, 'NVARCHAR2',         44, 'NCHAR',         45, 'UROWID',         46, '',         'UNDEFINED') as VARCHAR2(128)) as  DATA_TYPE,   cast(NULL as VARCHAR2(3)) as  DATA_TYPE_MOD,   cast(NULL as VARCHAR2(128)) as  DATA_TYPE_OWNER,   cast(c.data_length * CASE WHEN c.data_type in (22,23,30,43,44,46) and c.data_precision = 1                             THEN decode(c.collation_type, 63, 1, 249, 4, 248, 4, 87, 2, 28, 2, 55, 4, 54, 4, 101, 2, 46, 4, 45, 4, 224, 4, 1)                             ELSE 1 END                             as NUMBER) as DATA_LENGTH,   cast(CASE WHEN c.data_type in (11,12,17,18,19,22,23,27,28,29,30,36,37,38,43,44)             THEN NULL             ELSE CASE WHEN c.data_precision < 0 THEN NULL ELSE c.data_precision END        END as NUMBER) as  DATA_PRECISION,   cast(CASE WHEN c.data_type in (11,12,17,19,22,23,27,28,29,30,42,43,44)             THEN NULL             ELSE CASE WHEN c.data_scale < -84 THEN NULL ELSE c.data_scale END        END as NUMBER) as  DATA_SCALE,   cast(decode(c.nullable, 1, 'Y', 'N') as VARCHAR2(1)) as  NULLABLE,   cast(decode(BITAND(c.column_flags, 64), 0, c.column_id, NULL) as NUMBER) as  COLUMN_ID,   cast(LENGTHB(c.cur_default_value_v2) as NUMBER) as  DEFAULT_LENGTH,   cast(c.cur_default_value_v2 as /* TODO: LONG() */ VARCHAR(128)) as  DATA_DEFAULT,   cast(NULL as NUMBER) as  NUM_DISTINCT,   cast(NULL as /* TODO: RAW */ varchar(128)) as  LOW_VALUE,   cast(NULL as /* TODO: RAW */ varchar(128)) as  HIGH_VALUE,   cast(NULL as NUMBER) as  DENSITY,   cast(NULL as NUMBER) as  NUM_NULLS,   cast(NULL as NUMBER) as  NUM_BUCKETS,   cast(NULL as DATE) as  LAST_ANALYZED,   cast(NULL as NUMBER) as  SAMPLE_SIZE,   cast(decode(c.data_type,          22, 'CHAR_CS',          23, 'CHAR_CS',          30, decode(c.collation_type, 63, 'NULL', 'CHAR_CS'),          43, 'NCHAR_CS',          44, 'NCHAR_CS',          '') as VARCHAR2(44)) as CHARACTER_SET_NAME,   cast(NULL as NUMBER) as  CHAR_COL_DECL_LENGTH,   cast(NULL as VARCHAR2(3)) as  GLOBAL_STATS,   cast(NULL as VARCHAR2(3)) as  USER_STATS,   cast(NULL as VARCHAR2(80)) as  NOTES,   cast(NULL as NUMBER) as  AVG_COL_LEN,   cast(CASE WHEN c.data_type in (22,23,43,44) THEN c.data_length ELSE 0 END as NUMBER) as  CHAR_LENGTH,   cast(decode(c.data_type,          22, decode(c.data_precision, 1, 'C', 'B'),          23, decode(c.data_precision, 1, 'C', 'B'),          43, decode(c.data_precision, 1, 'C', 'B'),          44, decode(c.data_precision, 1, 'C', 'B'),          NULL) as VARCHAR2(1)) as  CHAR_USED,   cast(NULL as VARCHAR2(3)) as  V80_FMT_IMAGE,   cast(NULL as VARCHAR2(3)) as  DATA_UPGRADED,   cast(decode(BITAND(c.column_flags, 64), 0, 'NO', 'YES') as VARCHAR2(3)) as HIDDEN_COLUMN,   cast(decode(BITAND(c.column_flags, 1), 1, 'YES', 'NO') as VARCHAR2(3)) as  VIRTUAL_COLUMN,   cast(NULL as NUMBER) as  SEGMENT_COLUMN_ID,   cast(NULL as NUMBER) as  INTERNAL_COLUMN_ID,   cast(NULL as VARCHAR2(15)) as  HISTOGRAM,   cast(c.column_name as VARCHAR2(4000)) as  QUALIFIED_COL_NAME,   cast('YES' as VARCHAR2(3)) as  USER_GENERATED,   cast(NULL as VARCHAR2(3)) as  DEFAULT_ON_NULL,   cast(NULL as VARCHAR2(3)) as  IDENTITY_COLUMN,   cast(NULL as VARCHAR2(128)) as  EVALUATION_EDITION,   cast(NULL as VARCHAR2(128)) as  UNUSABLE_BEFORE,   cast(NULL as VARCHAR2(128)) as  UNUSABLE_BEGINNING,   cast(NULL as VARCHAR2(100)) as  COLLATION,   cast(NULL as NUMBER) as  COLLATED_COLUMN_ID FROM     sys.ALL_VIRTUAL_TABLE_REAL_AGENT t   JOIN     sys.ALL_VIRTUAL_DATABASE_REAL_AGENT db     ON db.tenant_id = t.tenant_id     AND db.database_id = t.database_id     AND (t.database_id = userenv('SCHEMAID')          OR user_can_access_obj(1, t.table_id, t.database_id) = 1)     AND T.TENANT_ID = EFFECTIVE_TENANT_ID()     AND DB.TENANT_ID = EFFECTIVE_TENANT_ID()   JOIN     sys.ALL_VIRTUAL_COLUMN_REAL_AGENT c     ON c.tenant_id = t.tenant_id     AND c.table_id = t.table_id     AND C.TENANT_ID = EFFECTIVE_TENANT_ID() WHERE   c.is_hidden = 0   AND t.table_type in (0,2,3,8,9) )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::dba_tab_cols_v_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_DBA_TAB_COLS_V_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_DBA_TAB_COLS_V_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT   cast(db.database_name as VARCHAR2(128)) as OWNER,   cast(t.table_name as VARCHAR2(128)) as  TABLE_NAME,   cast(c.column_name as VARCHAR2(128)) as  COLUMN_NAME,   cast(decode(c.data_type,         0, 'NULL',          1, 'NUMBER',         2, 'NUMBER',         3, 'NUMBER',         4, 'NUMBER',         5, 'NUMBER',          6, 'NUMBER',         7, 'NUMBER',         8, 'NUMBER',         9, 'NUMBER',         10, 'NUMBER',          11, 'BINARY_FLOAT',         12, 'BINARY_DOUBLE',          13, 'NUMBER',         14, 'NUMBER',          15, 'NUMBER',         16, 'NUMBER',          17, 'DATE',         18, 'TIMESTAMP',         19, 'DATE',         20, 'TIME',         21, 'YEAR',          22, 'VARCHAR2',         23, 'CHAR',         24, 'HEX_STRING',          25, 'EXT',         26, 'UNKNOWN',          27, 'TINYTEXT',         28, 'TEXT',         29, 'MEDIUMTEXT',         30, decode(c.collation_type, 63, 'BLOB', 'CLOB'),         31, 'BIT',         32, 'ENUM',         33, 'SET',         34, 'ENUM_INNER',         35, 'SET_INNER',         36, concat('TIMESTAMP(', concat(c.data_scale, ') WITH TIME ZONE')),         37, concat('TIMESTAMP(', concat(c.data_scale, ') WITH LOCAL TIME ZONE')),         38, concat('TIMESTAMP(', concat(c.data_scale, ')')),         39, 'RAW',         40, concat('INTERVAL YEAR(', concat(c.data_scale, ') TO MONTH')),         41, concat('INTERVAL DAY(', concat(trunc(c.data_scale/10), concat(') TO SECOND(', concat(mod(c.data_scale, 10), ')')))),         42, 'FLOAT',         43, 'NVARCHAR2',         44, 'NCHAR',         45, '',         'UNDEFINED') as VARCHAR2(128)) as  DATA_TYPE,   cast(NULL as VARCHAR2(3)) as  DATA_TYPE_MOD,   cast(NULL as VARCHAR2(128)) as  DATA_TYPE_OWNER,   cast(c.data_length * CASE WHEN c.data_type in (22,23,30,43,44,46) and c.data_precision = 1                             THEN decode(c.collation_type, 63, 1, 249, 4, 248, 4, 87, 2, 28, 2, 55, 4, 54, 4, 101, 2, 46, 4, 45, 4, 224, 4, 1)                             ELSE 1 END                             as NUMBER) as  DATA_LENGTH,   cast(CASE WHEN c.data_type in (11,12,17,18,19,22,23,27,28,29,30,36,37,38,43,44)             THEN NULL             ELSE CASE WHEN c.data_precision < 0 THEN NULL ELSE c.data_precision END        END as NUMBER) as  DATA_PRECISION,   cast(CASE WHEN c.data_type in (11,12,17,19,22,23,27,28,29,30,42,43,44)             THEN NULL             ELSE CASE WHEN c.data_scale < -84 THEN NULL ELSE c.data_scale END        END as NUMBER) as  DATA_SCALE,   cast(decode(c.nullable, 1, 'Y', 'N') as VARCHAR2(1)) as  NULLABLE,   cast(decode(BITAND(c.column_flags, 64), 0, c.column_id, NULL) as NUMBER) as  COLUMN_ID,   cast(LENGTHB(c.cur_default_value_v2) as NUMBER) as  DEFAULT_LENGTH,   cast(c.cur_default_value_v2 as /* TODO: LONG() */ VARCHAR(128)) as  DATA_DEFAULT,   cast(NULL as NUMBER) as  NUM_DISTINCT,   cast(NULL as /* TODO: RAW */ varchar(128)) as  LOW_VALUE,   cast(NULL as /* TODO: RAW */ varchar(128)) as  HIGH_VALUE,   cast(NULL as NUMBER) as  DENSITY,   cast(NULL as NUMBER) as  NUM_NULLS,   cast(NULL as NUMBER) as  NUM_BUCKETS,   cast(NULL as DATE) as  LAST_ANALYZED,   cast(NULL as NUMBER) as  SAMPLE_SIZE,   cast(decode(c.data_type,          22, 'CHAR_CS',          23, 'CHAR_CS',          30, decode(c.collation_type, 63, 'NULL', 'CHAR_CS'),          43, 'NCHAR_CS',          44, 'NCHAR_CS',          '') as VARCHAR2(44)) as  CHARACTER_SET_NAME,   cast(NULL as NUMBER) as  CHAR_COL_DECL_LENGTH,   cast(NULL as VARCHAR2(3)) as  GLOBAL_STATS,   cast(NULL as VARCHAR2(3)) as  USER_STATS,   cast(NULL as VARCHAR2(80)) as  NOTES,   cast(NULL as NUMBER) as  AVG_COL_LEN,   cast(CASE WHEN c.data_type in (22,23,43,44) THEN c.data_length ELSE 0 END as NUMBER) as  CHAR_LENGTH,   cast(decode(c.data_type,          22, decode(c.data_precision, 1, 'C', 'B'),          23, decode(c.data_precision, 1, 'C', 'B'),          43, decode(c.data_precision, 1, 'C', 'B'),          44, decode(c.data_precision, 1, 'C', 'B'),          NULL) as VARCHAR2(1)) as  CHAR_USED,   cast(NULL as VARCHAR2(3)) as  V80_FMT_IMAGE,   cast(NULL as VARCHAR2(3)) as  DATA_UPGRADED,   cast(decode(BITAND(c.column_flags, 64), 0, 'NO', 'YES') as VARCHAR2(3)) as HIDDEN_COLUMN,   cast(decode(BITAND(c.column_flags, 1), 1, 'YES', 'NO') as VARCHAR2(3)) as  VIRTUAL_COLUMN,   cast(NULL as NUMBER) as  SEGMENT_COLUMN_ID,   cast(NULL as NUMBER) as  INTERNAL_COLUMN_ID,   cast(NULL as VARCHAR2(15)) as  HISTOGRAM,   cast(c.column_name as VARCHAR2(4000)) as  QUALIFIED_COL_NAME,   cast('YES' as VARCHAR2(3)) as  USER_GENERATED,   cast(NULL as VARCHAR2(3)) as  DEFAULT_ON_NULL,   cast(NULL as VARCHAR2(3)) as  IDENTITY_COLUMN,   cast(NULL as VARCHAR2(128)) as  EVALUATION_EDITION,   cast(NULL as VARCHAR2(128)) as  UNUSABLE_BEFORE,   cast(NULL as VARCHAR2(128)) as  UNUSABLE_BEGINNING,   cast(NULL as VARCHAR2(100)) as  COLLATION,   cast(NULL as NUMBER) as  COLLATED_COLUMN_ID FROM     sys.ALL_VIRTUAL_TABLE_REAL_AGENT t   JOIN     sys.ALL_VIRTUAL_DATABASE_REAL_AGENT db     ON db.tenant_id = t.tenant_id     AND db.database_id = t.database_id     AND T.TENANT_ID = EFFECTIVE_TENANT_ID()     AND DB.TENANT_ID = EFFECTIVE_TENANT_ID()   JOIN     sys.ALL_VIRTUAL_COLUMN_REAL_AGENT c     ON c.tenant_id = t.tenant_id     AND c.table_id = t.table_id     AND C.TENANT_ID = EFFECTIVE_TENANT_ID() WHERE   c.is_hidden = 0   AND t.table_type in (0,2,3,8,9) )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::user_tab_cols_v_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_USER_TAB_COLS_V_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_USER_TAB_COLS_V_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT   cast(t.table_name as VARCHAR2(128)) as  TABLE_NAME,   cast(c.column_name as VARCHAR2(128)) as  COLUMN_NAME,   cast(decode(c.data_type,         0, 'NULL',          1, 'NUMBER',         2, 'NUMBER',         3, 'NUMBER',         4, 'NUMBER',         5, 'NUMBER',          6, 'NUMBER',         7, 'NUMBER',         8, 'NUMBER',         9, 'NUMBER',         10, 'NUMBER',          11, 'BINARY_FLOAT',         12, 'BINARY_DOUBLE',          13, 'NUMBER',         14, 'NUMBER',          15, 'NUMBER',         16, 'NUMBER',          17, 'DATE',         18, 'TIMESTAMP',         19, 'DATE',         20, 'TIME',         21, 'YEAR',          22, 'VARCHAR2',         23, 'CHAR',         24, 'HEX_STRING',          25, 'EXT',         26, 'UNKNOWN',          27, 'TINYTEXT',         28, 'TEXT',         29, 'MEDIUMTEXT',         30, decode(c.collation_type, 63, 'BLOB', 'CLOB'),         31, 'BIT',         32, 'ENUM',         33, 'SET',         34, 'ENUM_INNER',         35, 'SET_INNER',         36, concat('TIMESTAMP(', concat(c.data_scale, ') WITH TIME ZONE')),         37, concat('TIMESTAMP(', concat(c.data_scale, ') WITH LOCAL TIME ZONE')),         38, concat('TIMESTAMP(', concat(c.data_scale, ')')),         39, 'RAW',         40, concat('INTERVAL YEAR(', concat(c.data_scale, ') TO MONTH')),         41, concat('INTERVAL DAY(', concat(trunc(c.data_scale/10), concat(') TO SECOND(', concat(mod(c.data_scale, 10), ')')))),         42, 'FLOAT',         43, 'NVARCHAR2',         44, 'NCHAR',         45, '',         'UNDEFINED') as VARCHAR2(128)) as  DATA_TYPE,   cast(NULL as VARCHAR2(3)) as  DATA_TYPE_MOD,   cast(NULL as VARCHAR2(128)) as  DATA_TYPE_OWNER,   cast(c.data_length * CASE WHEN c.data_type in (22,23,30,43,44,46) and c.data_precision = 1                             THEN decode(c.collation_type, 63, 1, 249, 4, 248, 4, 87, 2, 28, 2, 55, 4, 54, 4, 101, 2, 46, 4, 45, 4, 224, 4, 1)                             ELSE 1 END                             as NUMBER) as  DATA_LENGTH,   cast(CASE WHEN c.data_type in (11,12,17,18,19,22,23,27,28,29,30,36,37,38,43,44)             THEN NULL             ELSE CASE WHEN c.data_precision < 0 THEN NULL ELSE c.data_precision END        END as NUMBER) as  DATA_PRECISION,   cast(CASE WHEN c.data_type in (11,12,17,19,22,23,27,28,29,30,42,43,44)             THEN NULL             ELSE CASE WHEN c.data_scale < -84 THEN NULL ELSE c.data_scale END        END as NUMBER) as  DATA_SCALE,   cast(decode(c.nullable, 1, 'Y', 'N') as VARCHAR2(1)) as  NULLABLE,   cast(decode(BITAND(c.column_flags, 64), 0, c.column_id, NULL) as NUMBER) as  COLUMN_ID,   cast(LENGTHB(c.cur_default_value_v2) as NUMBER) as  DEFAULT_LENGTH,   cast(c.cur_default_value_v2 as /* TODO: LONG() */ VARCHAR(128)) as  DATA_DEFAULT,   cast(NULL as NUMBER) as  NUM_DISTINCT,   cast(NULL as /* TODO: RAW */ varchar(128)) as  LOW_VALUE,   cast(NULL as /* TODO: RAW */ varchar(128)) as  HIGH_VALUE,   cast(NULL as NUMBER) as  DENSITY,   cast(NULL as NUMBER) as  NUM_NULLS,   cast(NULL as NUMBER) as  NUM_BUCKETS,   cast(NULL as DATE) as  LAST_ANALYZED,   cast(NULL as NUMBER) as  SAMPLE_SIZE,   cast(decode(c.data_type,          22, 'CHAR_CS',          23, 'CHAR_CS',          30, decode(c.collation_type, 63, 'NULL', 'CHAR_CS'),          43, 'NCHAR_CS',          44, 'NCHAR_CS',          '') as VARCHAR2(44)) as  CHARACTER_SET_NAME,   cast(NULL as NUMBER) as  CHAR_COL_DECL_LENGTH,   cast(NULL as VARCHAR2(3)) as  GLOBAL_STATS,   cast(NULL as VARCHAR2(3)) as  USER_STATS,   cast(NULL as VARCHAR2(80)) as  NOTES,   cast(NULL as NUMBER) as  AVG_COL_LEN,   cast(CASE WHEN c.data_type in (22,23,43,44) THEN c.data_length ELSE 0 END as NUMBER) as  CHAR_LENGTH,   cast(decode(c.data_type,          22, decode(c.data_precision, 1, 'C', 'B'),          23, decode(c.data_precision, 1, 'C', 'B'),          43, decode(c.data_precision, 1, 'C', 'B'),          44, decode(c.data_precision, 1, 'C', 'B'),          NULL) as VARCHAR2(1)) as  CHAR_USED,   cast(NULL as VARCHAR2(3)) as  V80_FMT_IMAGE,   cast(NULL as VARCHAR2(3)) as  DATA_UPGRADED,   cast(decode(BITAND(c.column_flags, 64), 0, 'NO', 'YES') as VARCHAR2(3)) as HIDDEN_COLUMN,   cast(decode(BITAND(c.column_flags, 1), 1, 'YES', 'NO') as VARCHAR2(3)) as  VIRTUAL_COLUMN,   cast(NULL as NUMBER) as  SEGMENT_COLUMN_ID,   cast(NULL as NUMBER) as  INTERNAL_COLUMN_ID,   cast(NULL as VARCHAR2(15)) as  HISTOGRAM,   cast(c.column_name as VARCHAR2(4000)) as  QUALIFIED_COL_NAME,   cast('YES' as VARCHAR2(3)) as  USER_GENERATED,   cast(NULL as VARCHAR2(3)) as  DEFAULT_ON_NULL,   cast(NULL as VARCHAR2(3)) as  IDENTITY_COLUMN,   cast(NULL as VARCHAR2(128)) as  EVALUATION_EDITION,   cast(NULL as VARCHAR2(128)) as  UNUSABLE_BEFORE,   cast(NULL as VARCHAR2(128)) as  UNUSABLE_BEGINNING,   cast(NULL as VARCHAR2(100)) as  COLLATION,   cast(NULL as NUMBER) as  COLLATED_COLUMN_ID FROM     sys.ALL_VIRTUAL_TABLE_REAL_AGENT t   JOIN     sys.ALL_VIRTUAL_COLUMN_REAL_AGENT c     ON c.tenant_id = t.tenant_id     AND c.table_id = t.table_id     AND T.TENANT_ID = EFFECTIVE_TENANT_ID()     AND C.TENANT_ID = EFFECTIVE_TENANT_ID() WHERE   c.is_hidden = 0   AND t.table_type in (0,2,3,8,9)   AND t.database_id = USERENV('SCHEMAID') )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::all_tab_cols_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_ALL_TAB_COLS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_ALL_TAB_COLS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(select   OWNER, TABLE_NAME,   COLUMN_NAME, DATA_TYPE, DATA_TYPE_MOD, DATA_TYPE_OWNER,   DATA_LENGTH, DATA_PRECISION, DATA_SCALE, NULLABLE, COLUMN_ID,   DEFAULT_LENGTH, DATA_DEFAULT, NUM_DISTINCT, LOW_VALUE, HIGH_VALUE,   DENSITY, NUM_NULLS, NUM_BUCKETS, LAST_ANALYZED, SAMPLE_SIZE,   CHARACTER_SET_NAME, CHAR_COL_DECL_LENGTH,   GLOBAL_STATS,   USER_STATS, AVG_COL_LEN, CHAR_LENGTH, CHAR_USED,   V80_FMT_IMAGE, DATA_UPGRADED, HIDDEN_COLUMN, VIRTUAL_COLUMN,   SEGMENT_COLUMN_ID, INTERNAL_COLUMN_ID, HISTOGRAM, QUALIFIED_COL_NAME   from SYS.all_tab_cols_v$ )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::dba_tab_cols_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_DBA_TAB_COLS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_DBA_TAB_COLS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__( select   OWNER, TABLE_NAME,   COLUMN_NAME, DATA_TYPE, DATA_TYPE_MOD, DATA_TYPE_OWNER,   DATA_LENGTH, DATA_PRECISION, DATA_SCALE, NULLABLE, COLUMN_ID,   DEFAULT_LENGTH, DATA_DEFAULT, NUM_DISTINCT, LOW_VALUE, HIGH_VALUE,   DENSITY, NUM_NULLS, NUM_BUCKETS, LAST_ANALYZED, SAMPLE_SIZE,   CHARACTER_SET_NAME, CHAR_COL_DECL_LENGTH,   GLOBAL_STATS,   USER_STATS, AVG_COL_LEN, CHAR_LENGTH, CHAR_USED,   V80_FMT_IMAGE, DATA_UPGRADED, HIDDEN_COLUMN, VIRTUAL_COLUMN,   SEGMENT_COLUMN_ID, INTERNAL_COLUMN_ID, HISTOGRAM, QUALIFIED_COL_NAME from SYS.dba_tab_cols_v$ )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::user_tab_cols_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_USER_TAB_COLS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_USER_TAB_COLS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(select   TABLE_NAME, COLUMN_NAME, DATA_TYPE, DATA_TYPE_MOD, DATA_TYPE_OWNER,   DATA_LENGTH, DATA_PRECISION, DATA_SCALE, NULLABLE, COLUMN_ID,   DEFAULT_LENGTH, DATA_DEFAULT, NUM_DISTINCT, LOW_VALUE, HIGH_VALUE,   DENSITY, NUM_NULLS, NUM_BUCKETS, LAST_ANALYZED, SAMPLE_SIZE,   CHARACTER_SET_NAME, CHAR_COL_DECL_LENGTH,   GLOBAL_STATS,   USER_STATS, AVG_COL_LEN, CHAR_LENGTH, CHAR_USED,   V80_FMT_IMAGE, DATA_UPGRADED, HIDDEN_COLUMN, VIRTUAL_COLUMN,   SEGMENT_COLUMN_ID, INTERNAL_COLUMN_ID, HISTOGRAM, QUALIFIED_COL_NAME   from SYS.user_tab_cols_v$ )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::all_tab_columns_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_ALL_TAB_COLUMNS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_ALL_TAB_COLUMNS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(select   OWNER, TABLE_NAME,   COLUMN_NAME, DATA_TYPE, DATA_TYPE_MOD, DATA_TYPE_OWNER,   DATA_LENGTH, DATA_PRECISION, DATA_SCALE, NULLABLE, COLUMN_ID,   DEFAULT_LENGTH, DATA_DEFAULT, NUM_DISTINCT, LOW_VALUE, HIGH_VALUE,   DENSITY, NUM_NULLS, NUM_BUCKETS, LAST_ANALYZED, SAMPLE_SIZE,   CHARACTER_SET_NAME, CHAR_COL_DECL_LENGTH,   GLOBAL_STATS, USER_STATS, AVG_COL_LEN, CHAR_LENGTH, CHAR_USED,   V80_FMT_IMAGE, DATA_UPGRADED, HISTOGRAM   from SYS.ALL_TAB_COLS )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::dba_tab_columns_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_DBA_TAB_COLUMNS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_DBA_TAB_COLUMNS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__( select   OWNER, TABLE_NAME,   COLUMN_NAME, DATA_TYPE, DATA_TYPE_MOD, DATA_TYPE_OWNER,   DATA_LENGTH, DATA_PRECISION, DATA_SCALE, NULLABLE, COLUMN_ID,   DEFAULT_LENGTH, DATA_DEFAULT, NUM_DISTINCT, LOW_VALUE, HIGH_VALUE,   DENSITY, NUM_NULLS, NUM_BUCKETS, LAST_ANALYZED, SAMPLE_SIZE,   CHARACTER_SET_NAME, CHAR_COL_DECL_LENGTH,   GLOBAL_STATS, USER_STATS, AVG_COL_LEN, CHAR_LENGTH, CHAR_USED,   V80_FMT_IMAGE, DATA_UPGRADED, HISTOGRAM from SYS.DBA_TAB_COLS )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::user_tab_columns_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_USER_TAB_COLUMNS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_USER_TAB_COLUMNS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(select   TABLE_NAME, COLUMN_NAME, DATA_TYPE, DATA_TYPE_MOD, DATA_TYPE_OWNER,   DATA_LENGTH, DATA_PRECISION, DATA_SCALE, NULLABLE, COLUMN_ID,   DEFAULT_LENGTH, DATA_DEFAULT, NUM_DISTINCT, LOW_VALUE, HIGH_VALUE,   DENSITY, NUM_NULLS, NUM_BUCKETS, LAST_ANALYZED, SAMPLE_SIZE,   CHARACTER_SET_NAME, CHAR_COL_DECL_LENGTH,   GLOBAL_STATS, USER_STATS, AVG_COL_LEN, CHAR_LENGTH, CHAR_USED,   V80_FMT_IMAGE, DATA_UPGRADED, HISTOGRAM   from SYS.USER_TAB_COLS )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::all_tables_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_ALL_TABLES_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_ALL_TABLES_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT   CAST(db.database_name AS VARCHAR2(128)) AS OWNER,   CAST(t.table_name AS VARCHAR2(128)) AS TABLE_NAME,   CAST(tp.tablespace_name AS VARCHAR2(30)) AS TABLESPACE_NAME,   CAST(NULL AS VARCHAR2(128)) AS CLUSTER_NAME,   CAST(NULL AS VARCHAR2(128)) AS IOT_NAME,   CAST('VALID' AS VARCHAR2(8)) AS STATUS,   CAST(t."PCTFREE" AS NUMBER) AS PCT_FREE,   CAST(NULL AS NUMBER) AS PCT_USED,   CAST(NULL AS NUMBER) AS INI_TRANS,   CAST(NULL AS NUMBER) AS MAX_TRANS,   CAST(NULL AS NUMBER) AS INITIAL_EXTENT,   CAST(NULL AS NUMBER) AS NEXT_EXTENT,   CAST(NULL AS NUMBER) AS MIN_EXTENTS,   CAST(NULL AS NUMBER) AS MAX_EXTENTS,   CAST(NULL AS NUMBER) AS PCT_INCREASE,   CAST(NULL AS NUMBER) AS FREELISTS,   CAST(NULL AS NUMBER) AS FREELIST_GROUPS,   CAST(NULL AS VARCHAR2(3)) AS LOGGING,   CAST(NULL AS VARCHAR2(1)) AS BACKED_UP,   CAST(info.row_count AS NUMBER) AS NUM_ROWS,   CAST(NULL AS NUMBER) AS BLOCKS,   CAST(NULL AS NUMBER) AS EMPTY_BLOCKS,   CAST(NULL AS NUMBER) AS AVG_SPACE,   CAST(NULL AS NUMBER) AS CHAIN_CNT,   CAST(NULL AS NUMBER) AS AVG_ROW_LEN,   CAST(NULL AS NUMBER) AS AVG_SPACE_FREELIST_BLOCKS,   CAST(NULL AS NUMBER) AS NUM_FREELIST_BLOCKS,   CAST(NULL AS VARCHAR2(40)) AS DEGREE,   CAST(NULL AS VARCHAR2(40)) AS INSTANCES,   CAST(NULL AS VARCHAR2(20)) AS CACHE,   CAST(NULL AS VARCHAR2(8)) AS TABLE_LOCK,   CAST(NULL AS NUMBER) AS SAMPLE_SIZE,   CAST(NULL AS DATE) AS LAST_ANALYZED,   CAST(   CASE     WHEN       t.part_level = 0     THEN       'NO'     ELSE       'YES'   END   AS VARCHAR2(3)) AS PARTITIONED,   CAST(NULL AS VARCHAR2(12)) AS IOT_TYPE,   CAST(decode (t.table_type, 8, 'YES', 9, 'YES', 'NO') AS VARCHAR2(1)) AS TEMPORARY,   CAST(NULL AS VARCHAR2(1)) AS SECONDARY,   CAST('NO' AS VARCHAR2(3)) AS NESTED,   CAST(NULL AS VARCHAR2(7)) AS BUFFER_POOL,   CAST(NULL AS VARCHAR2(7)) AS FLASH_CACHE,   CAST(NULL AS VARCHAR2(7)) AS CELL_FLASH_CACHE,   CAST(NULL AS VARCHAR2(8)) AS ROW_MOVEMENT,   CAST(NULL AS VARCHAR2(3)) AS GLOBAL_STATS,   CAST(NULL AS VARCHAR2(3)) AS USER_STATS,   CAST( decode (t.table_type, 8, 'SYS$SESSION', 9, 'SYS$TRANSACTION', NULL) AS VARCHAR2(15)) AS DURATION,   CAST(NULL AS VARCHAR2(8)) AS SKIP_CORRUPT,   CAST(NULL AS VARCHAR2(3)) AS MONITORING,   CAST(NULL AS VARCHAR2(30)) AS CLUSTER_OWNER,   CAST(NULL AS VARCHAR2(8)) AS DEPENDENCIES,   CAST(NULL AS VARCHAR2(8)) AS COMPRESSION,   CAST(NULL AS VARCHAR2(12)) AS COMPRESS_FOR,   CAST(   CASE     WHEN       db.database_name =  '__recyclebin'     THEN 'YES'     ELSE       'NO'   END   AS VARCHAR2(3)) AS DROPPED,   CAST(NULL AS VARCHAR2(3)) AS READ_ONLY,   CAST(NULL AS VARCHAR2(3)) AS SEGMENT_CREATED,   CAST(NULL AS VARCHAR2(7)) AS RESULT_CACHE FROM   (     SELECT       tenant_id,       table_id,       SUM(row_count) AS row_count     FROM       sys.ALL_VIRTUAL_TENANT_PARTITION_META_TABLE_REAL_AGENT p     WHERE       p.role = 1       AND P.TENANT_ID = EFFECTIVE_TENANT_ID()     GROUP BY       tenant_id,       table_id   )   info   RIGHT JOIN     sys.ALL_VIRTUAL_TABLE_REAL_AGENT t     ON t.tenant_id = info.tenant_id     AND t.table_id = info.table_id     AND T.TENANT_ID = EFFECTIVE_TENANT_ID() JOIN   sys.ALL_VIRTUAL_DATABASE_REAL_AGENT db ON   db.tenant_id = t.tenant_id   AND db.database_id = t.database_id   AND db.database_name != '__recyclebin'   AND t.table_type in (3, 8, 9, 11)   AND DB.TENANT_ID = EFFECTIVE_TENANT_ID()   AND (t.database_id = USERENV('SCHEMAID')          or user_can_access_obj(1, t.table_id, t.database_id) =1) LEFT JOIN   sys.ALL_VIRTUAL_TENANT_TABLESPACE_REAL_AGENT tp ON   tp.tablespace_id = t.tablespace_id   AND t.tenant_id = tp.tenant_id   AND TP.TENANT_ID = EFFECTIVE_TENANT_ID() WHERE t.session_id = 0 )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::dba_tables_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_DBA_TABLES_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_DBA_TABLES_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT   CAST(db.database_name AS VARCHAR2(128)) AS OWNER,   CAST(t.table_name AS VARCHAR2(128)) AS TABLE_NAME,   CAST(tp.tablespace_name AS VARCHAR2(30)) AS TABLESPACE_NAME,   CAST(NULL AS VARCHAR2(128)) AS CLUSTER_NAME,   CAST(NULL AS VARCHAR2(128)) AS IOT_NAME,   CAST('VALID' AS VARCHAR2(8)) AS STATUS,   CAST(t."PCTFREE" AS NUMBER) AS PCT_FREE,   CAST(NULL AS NUMBER) AS PCT_USED,   CAST(NULL AS NUMBER) AS INI_TRANS,   CAST(NULL AS NUMBER) AS MAX_TRANS,   CAST(NULL AS NUMBER) AS INITIAL_EXTENT,   CAST(NULL AS NUMBER) AS NEXT_EXTENT,   CAST(NULL AS NUMBER) AS MIN_EXTENTS,   CAST(NULL AS NUMBER) AS MAX_EXTENTS,   CAST(NULL AS NUMBER) AS PCT_INCREASE,   CAST(NULL AS NUMBER) AS FREELISTS,   CAST(NULL AS NUMBER) AS FREELIST_GROUPS,   CAST(NULL AS VARCHAR2(3)) AS LOGGING,   CAST(NULL AS VARCHAR2(1)) AS BACKED_UP,   CAST(info.row_count AS NUMBER) AS NUM_ROWS,   CAST(NULL AS NUMBER) AS BLOCKS,   CAST(NULL AS NUMBER) AS EMPTY_BLOCKS,   CAST(NULL AS NUMBER) AS AVG_SPACE,   CAST(NULL AS NUMBER) AS CHAIN_CNT,   CAST(NULL AS NUMBER) AS AVG_ROW_LEN,   CAST(NULL AS NUMBER) AS AVG_SPACE_FREELIST_BLOCKS,   CAST(NULL AS NUMBER) AS NUM_FREELIST_BLOCKS,   CAST(NULL AS VARCHAR2(40)) AS DEGREE,   CAST(NULL AS VARCHAR2(40)) AS INSTANCES,   CAST(NULL AS VARCHAR2(20)) AS CACHE,   CAST(NULL AS VARCHAR2(8)) AS TABLE_LOCK,   CAST(NULL AS NUMBER) AS SAMPLE_SIZE,   CAST(NULL AS DATE) AS LAST_ANALYZED,   CAST(   CASE     WHEN       t.part_level = 0     THEN       'NO'     ELSE       'YES'   END   AS VARCHAR2(3)) AS PARTITIONED,   CAST(NULL AS VARCHAR2(12)) AS IOT_TYPE,   CAST(decode (t.table_type, 8, 'YES', 9, 'YES', 'NO') AS VARCHAR2(1)) AS TEMPORARY,   CAST(NULL AS VARCHAR2(1)) AS SECONDARY,   CAST('NO' AS VARCHAR2(3)) AS NESTED,   CAST(NULL AS VARCHAR2(7)) AS BUFFER_POOL,   CAST(NULL AS VARCHAR2(7)) AS FLASH_CACHE,   CAST(NULL AS VARCHAR2(7)) AS CELL_FLASH_CACHE,   CAST(NULL AS VARCHAR2(8)) AS ROW_MOVEMENT,   CAST(NULL AS VARCHAR2(3)) AS GLOBAL_STATS,   CAST(NULL AS VARCHAR2(3)) AS USER_STATS,   CAST( decode (t.table_type, 8, 'SYS$SESSION', 9, 'SYS$TRANSACTION', NULL) AS VARCHAR2(15)) AS DURATION,   CAST(NULL AS VARCHAR2(8)) AS SKIP_CORRUPT,   CAST(NULL AS VARCHAR2(3)) AS MONITORING,   CAST(NULL AS VARCHAR2(30)) AS CLUSTER_OWNER,   CAST(NULL AS VARCHAR2(8)) AS DEPENDENCIES,   CAST(NULL AS VARCHAR2(8)) AS COMPRESSION,   CAST(NULL AS VARCHAR2(12)) AS COMPRESS_FOR,   CAST(   CASE     WHEN       db.database_name =  '__recyclebin'     THEN 'YES'     ELSE       'NO'   END   AS VARCHAR2(3)) AS DROPPED,   CAST(NULL AS VARCHAR2(3)) AS READ_ONLY,   CAST(NULL AS VARCHAR2(3)) AS SEGMENT_CREATED,   CAST(NULL AS VARCHAR2(7)) AS RESULT_CACHE FROM   (     SELECT       tenant_id,       table_id,       SUM(row_count) AS row_count     FROM       sys.ALL_VIRTUAL_TENANT_PARTITION_META_TABLE_REAL_AGENT p     WHERE       p.role = 1       AND P.TENANT_ID = EFFECTIVE_TENANT_ID()     GROUP BY       tenant_id,       table_id   )   info   RIGHT JOIN     sys.ALL_VIRTUAL_TABLE_REAL_AGENT t     ON t.tenant_id = info.tenant_id     AND t.table_id = info.table_id   JOIN     sys.ALL_VIRTUAL_DATABASE_REAL_AGENT db   ON     db.tenant_id = t.tenant_id     AND db.database_id = t.database_id     AND db.database_name != '__recyclebin'     AND t.table_type in (3, 8, 9, 11)     AND DB.TENANT_ID = EFFECTIVE_TENANT_ID()   LEFT JOIN     sys.ALL_VIRTUAL_TENANT_TABLESPACE_REAL_AGENT tp   ON     tp.tablespace_id = t.tablespace_id     AND t.tenant_id = tp.tenant_id     AND TP.TENANT_ID = EFFECTIVE_TENANT_ID()   WHERE t.session_id = 0 )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::user_tables_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_USER_TABLES_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_USER_TABLES_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT   CAST(t.table_name AS VARCHAR2(128)) AS TABLE_NAME,   CAST(tp.tablespace_name AS VARCHAR2(30)) AS TABLESPACE_NAME,   CAST(NULL AS VARCHAR2(128)) AS CLUSTER_NAME,   CAST(NULL AS VARCHAR2(128)) AS IOT_NAME,   CAST('VALID' AS VARCHAR2(8)) AS STATUS,   CAST(t."PCTFREE" AS NUMBER) AS PCT_FREE,   CAST(NULL AS NUMBER) AS PCT_USED,   CAST(NULL AS NUMBER) AS INI_TRANS,   CAST(NULL AS NUMBER) AS MAX_TRANS,   CAST(NULL AS NUMBER) AS INITIAL_EXTENT,   CAST(NULL AS NUMBER) AS NEXT_EXTENT,   CAST(NULL AS NUMBER) AS MIN_EXTENTS,   CAST(NULL AS NUMBER) AS MAX_EXTENTS,   CAST(NULL AS NUMBER) AS PCT_INCREASE,   CAST(NULL AS NUMBER) AS FREELISTS,   CAST(NULL AS NUMBER) AS FREELIST_GROUPS,   CAST(NULL AS VARCHAR2(3)) AS LOGGING,   CAST(NULL AS VARCHAR2(1)) AS BACKED_UP,   CAST(info.row_count AS NUMBER) AS NUM_ROWS,   CAST(NULL AS NUMBER) AS BLOCKS,   CAST(NULL AS NUMBER) AS EMPTY_BLOCKS,   CAST(NULL AS NUMBER) AS AVG_SPACE,   CAST(NULL AS NUMBER) AS CHAIN_CNT,   CAST(NULL AS NUMBER) AS AVG_ROW_LEN,   CAST(NULL AS NUMBER) AS AVG_SPACE_FREELIST_BLOCKS,   CAST(NULL AS NUMBER) AS NUM_FREELIST_BLOCKS,   CAST(NULL AS VARCHAR2(40)) AS DEGREE,   CAST(NULL AS VARCHAR2(40)) AS INSTANCES,   CAST(NULL AS VARCHAR2(20)) AS CACHE,   CAST(NULL AS VARCHAR2(8)) AS TABLE_LOCK,   CAST(NULL AS NUMBER) AS SAMPLE_SIZE,   CAST(NULL AS DATE) AS LAST_ANALYZED,   CAST(   CASE     WHEN       t.part_level = 0     THEN       'NO'     ELSE       'YES'   END   AS VARCHAR2(3)) AS PARTITIONED,   CAST(NULL AS VARCHAR2(12)) AS IOT_TYPE,   CAST(decode (t.table_type, 8, 'YES', 9, 'YES', 'NO') AS VARCHAR2(1)) AS TEMPORARY,   CAST(NULL AS VARCHAR2(1)) AS SECONDARY,   CAST('NO' AS VARCHAR2(3)) AS NESTED,   CAST(NULL AS VARCHAR2(7)) AS BUFFER_POOL,   CAST(NULL AS VARCHAR2(7)) AS FLASH_CACHE,   CAST(NULL AS VARCHAR2(7)) AS CELL_FLASH_CACHE,   CAST(NULL AS VARCHAR2(8)) AS ROW_MOVEMENT,   CAST(NULL AS VARCHAR2(3)) AS GLOBAL_STATS,   CAST(NULL AS VARCHAR2(3)) AS USER_STATS,   CAST( decode (t.table_type, 8, 'SYS$SESSION', 9, 'SYS$TRANSACTION', NULL) AS VARCHAR2(15)) AS DURATION,   CAST(NULL AS VARCHAR2(8)) AS SKIP_CORRUPT,   CAST(NULL AS VARCHAR2(3)) AS MONITORING,   CAST(NULL AS VARCHAR2(30)) AS CLUSTER_OWNER,   CAST(NULL AS VARCHAR2(8)) AS DEPENDENCIES,   CAST(NULL AS VARCHAR2(8)) AS COMPRESSION,   CAST(NULL AS VARCHAR2(12)) AS COMPRESS_FOR,   CAST(   CASE     WHEN       db.database_name =  '__recyclebin'     THEN 'YES'     ELSE       'NO'   END   AS VARCHAR2(3)) AS DROPPED,   CAST(NULL AS VARCHAR2(3)) AS READ_ONLY,   CAST(NULL AS VARCHAR2(3)) AS SEGMENT_CREATED,   CAST(NULL AS VARCHAR2(7)) AS RESULT_CACHE FROM   (     SELECT       tenant_id,       table_id,       SUM(row_count) AS row_count     FROM       sys.ALL_VIRTUAL_TENANT_PARTITION_META_TABLE_REAL_AGENT p     WHERE       p.role = 1       AND P.TENANT_ID = EFFECTIVE_TENANT_ID()     GROUP BY       tenant_id,       table_id   )   info   RIGHT JOIN     sys.ALL_VIRTUAL_TABLE_REAL_AGENT t     ON t.tenant_id = info.tenant_id     AND t.table_id = info.table_id     AND T.TENANT_ID = EFFECTIVE_TENANT_ID()   JOIN     sys.ALL_VIRTUAL_DATABASE_REAL_AGENT db   ON     db.tenant_id = t.tenant_id     AND db.database_id = t.database_id     AND t.database_id = USERENV('SCHEMAID')     AND t.table_type in (3, 8, 9, 11)     AND DB.TENANT_ID = EFFECTIVE_TENANT_ID()   LEFT JOIN     sys.ALL_VIRTUAL_TENANT_TABLESPACE_REAL_AGENT tp   ON     tp.tablespace_id = t.tablespace_id     AND t.tenant_id = tp.tenant_id     AND TP.TENANT_ID = EFFECTIVE_TENANT_ID()   WHERE t.session_id = 0 )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::dba_tab_comments_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_DBA_TAB_COMMENTS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_DBA_TAB_COMMENTS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT       A.DATABASE_NAME AS OWNER,       CAST(B.TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,       CAST(CASE WHEN TABLE_TYPE = 0 OR TABLE_TYPE = 2 OR TABLE_TYPE = 3 OR TABLE_TYPE = 5 OR TABLE_TYPE = 8 OR TABLE_TYPE = 9 THEN   'TABLE' WHEN TABLE_TYPE = 1 OR TABLE_TYPE = 4 OR TABLE_TYPE = 7 THEN 'VIEW' ELSE NULL END AS VARCHAR2(11)) AS TABLE_TYPE,       CAST(B."COMMENT" AS VARCHAR(4000)) AS COMMENTS     FROM       SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT A       JOIN SYS.ALL_VIRTUAL_TABLE_REAL_AGENT B     ON A.DATABASE_ID = B.DATABASE_ID     AND A.TENANT_ID = EFFECTIVE_TENANT_ID()     AND B.TENANT_ID = EFFECTIVE_TENANT_ID() )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::all_tab_comments_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_ALL_TAB_COMMENTS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_ALL_TAB_COMMENTS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT       A.DATABASE_NAME AS OWNER,       CAST(B.TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,       CAST(CASE WHEN TABLE_TYPE = 0 OR TABLE_TYPE = 2 OR TABLE_TYPE = 3 OR TABLE_TYPE = 5 OR TABLE_TYPE = 8 OR TABLE_TYPE = 9 THEN   'TABLE' WHEN TABLE_TYPE = 1 OR TABLE_TYPE = 4 OR TABLE_TYPE = 7 THEN 'VIEW' ELSE NULL END AS VARCHAR2(11)) AS TABLE_TYPE,       CAST(B."COMMENT" AS VARCHAR(4000)) AS COMMENTS     FROM       SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT A       JOIN SYS.ALL_VIRTUAL_TABLE_REAL_AGENT B     ON A.DATABASE_ID = B.DATABASE_ID     AND A.TENANT_ID = EFFECTIVE_TENANT_ID()     AND B.TENANT_ID = EFFECTIVE_TENANT_ID()     AND (A.DATABASE_ID = USERENV('SCHEMAID')         OR USER_CAN_ACCESS_OBJ(1, TABLE_ID, A.DATABASE_ID) = 1) )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::user_tab_comments_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_USER_TAB_COMMENTS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_USER_TAB_COMMENTS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT       CAST(B.TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,       CAST(CASE WHEN TABLE_TYPE = 0 OR TABLE_TYPE = 2 OR TABLE_TYPE = 3 OR TABLE_TYPE = 5 OR TABLE_TYPE = 8 OR TABLE_TYPE = 9 THEN   'TABLE' WHEN TABLE_TYPE = 1 OR TABLE_TYPE = 4 OR TABLE_TYPE = 7 THEN 'VIEW' ELSE NULL END AS VARCHAR2(11)) AS TABLE_TYPE,       CAST(B."COMMENT" AS VARCHAR(4000)) AS COMMENTS     FROM       SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT A       JOIN SYS.ALL_VIRTUAL_TABLE_REAL_AGENT B     ON A.DATABASE_ID = B.DATABASE_ID     AND A.TENANT_ID = EFFECTIVE_TENANT_ID()     AND B.TENANT_ID = EFFECTIVE_TENANT_ID()     AND A.DATABASE_NAME = SYS_CONTEXT('USERENV','CURRENT_USER') )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::dba_col_comments_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_DBA_COL_COMMENTS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_DBA_COL_COMMENTS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT       A.DATABASE_NAME AS OWNER,       CAST(B.TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,       C.COLUMN_NAME AS COLUMN_NAME,       CAST(C."COMMENT" AS VARCHAR(4000)) AS COMMENTS     FROM       SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT A,       SYS.ALL_VIRTUAL_TABLE_REAL_AGENT B,       SYS.ALL_VIRTUAL_COLUMN_REAL_AGENT C     WHERE       A.DATABASE_ID = B.DATABASE_ID       AND B.TABLE_ID = C.TABLE_ID       AND A.TENANT_ID = EFFECTIVE_TENANT_ID()       AND B.TENANT_ID = EFFECTIVE_TENANT_ID()       AND C.TENANT_ID = EFFECTIVE_TENANT_ID() )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::all_col_comments_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_ALL_COL_COMMENTS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_ALL_COL_COMMENTS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT       A.DATABASE_NAME AS OWNER,       CAST(B.TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,       C.COLUMN_NAME AS COLUMN_NAME,       CAST(C."COMMENT" AS VARCHAR(4000)) AS COMMENTS     FROM     SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT A,       SYS.ALL_VIRTUAL_TABLE_REAL_AGENT B,       SYS.ALL_VIRTUAL_COLUMN_REAL_AGENT C     WHERE       A.DATABASE_ID = B.DATABASE_ID       AND B.TABLE_ID = C.TABLE_ID       AND A.TENANT_ID = EFFECTIVE_TENANT_ID()       AND B.TENANT_ID = EFFECTIVE_TENANT_ID()       AND C.TENANT_ID = EFFECTIVE_TENANT_ID()       AND (A.DATABASE_ID = USERENV('SCHEMAID')            OR USER_CAN_ACCESS_OBJ(1, B.TABLE_ID, B.DATABASE_ID) = 1) )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::user_col_comments_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_USER_COL_COMMENTS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_USER_COL_COMMENTS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT       CAST(B.TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,       C.COLUMN_NAME AS COLUMN_NAME,       CAST(C."COMMENT" AS VARCHAR(4000)) AS COMMENTS     FROM       SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT A,       SYS.ALL_VIRTUAL_TABLE_REAL_AGENT B,       SYS.ALL_VIRTUAL_COLUMN_REAL_AGENT C     WHERE       A.DATABASE_ID = B.DATABASE_ID       AND B.TABLE_ID = C.TABLE_ID       AND A.TENANT_ID = EFFECTIVE_TENANT_ID()       AND B.TENANT_ID = EFFECTIVE_TENANT_ID()       AND C.TENANT_ID = EFFECTIVE_TENANT_ID()       AND A.DATABASE_NAME = SYS_CONTEXT('USERENV','CURRENT_USER') )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::dba_indexes_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_DBA_INDEXES_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_DBA_INDEXES_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT       CAST(INDEX_OWNER AS VARCHAR2(128)) AS OWNER,       CAST(INDEX_NAME AS VARCHAR2(128)) AS INDEX_NAME,       CAST(INDEX_TYPE_NAME AS VARCHAR2(27)) AS INDEX_TYPE,       CAST(TABLE_OWNER AS VARCHAR2(128)) AS TABLE_OWNER,       CAST(TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,       CAST('TABLE' AS CHAR(5)) AS TABLE_TYPE,       CAST(UNIQUENESS AS VARCHAR2(9)) AS UNIQUENESS,       CAST(COMPRESSION AS VARCHAR2(8)) AS COMPRESSION,       CAST(NULL AS NUMBER) AS PREFIX_LENGTH,       CAST(TABLESPACE_NAME AS VARCHAR2(30)) AS TABLESPACE_NAME,       CAST(NULL AS NUMBER) AS INI_TRANS,       CAST(NULL AS NUMBER) AS MAX_TRANS,       CAST(NULL AS NUMBER) AS INITIAL_EXTENT,       CAST(NULL AS NUMBER) AS NEXT_EXTENT,       CAST(NULL AS NUMBER) AS MIN_EXTENTS,       CAST(NULL AS NUMBER) AS MAX_EXTENTS,       CAST(NULL AS NUMBER) AS PCT_INCREASE,       CAST(NULL AS NUMBER) AS PCT_THRESHOLD,       CAST(NULL AS NUMBER) AS INCLUDE_COLUMN,       CAST(NULL AS NUMBER) AS FREELISTS,       CAST(NULL AS NUMBER) AS FREELIST_GROUPS,       CAST(NULL AS NUMBER) AS PCT_FREE,       CAST(NULL AS VARCHAR2(3)) AS LOGGING,       CAST(NULL AS NUMBER) AS BLEVEL,       CAST(NULL AS NUMBER) AS LEAF_BLOCKS,       CAST(NULL AS NUMBER) AS DISTINCT_KEYS,       CAST(NULL AS NUMBER) AS AVG_LEAF_BLOCKS_PER_KEY,       CAST(NULL AS NUMBER) AS AVG_DATA_BLOCKS_PER_KEY,       CAST(NULL AS NUMBER) AS CLUSTERING_FACTOR,       CAST(STATUS AS VARCHAR2(10)) AS STATUS,       CAST(NULL AS NUMBER) AS NUM_ROWS,       CAST(NULL AS NUMBER) AS SAMPLE_SIZE,       CAST(NULL AS DATE) AS LAST_ANALYZED,       CAST(NULL AS VARCHAR2(40)) AS DEGREE,       CAST(NULL AS VARCHAR2(40)) AS INSTANCES,       CAST(CASE WHEN A_TABLE_TYPE = 3 THEN 'NO'                 WHEN A_INDEX_TYPE = 1 OR A_INDEX_TYPE = 2                 THEN (CASE WHEN D.PART_LEVEL = 0 THEN 'NO' ELSE 'YES' END)            ELSE (CASE WHEN A_PART_LEVEL = 0 THEN 'NO' ELSE 'YES' END) END  AS VARCHAR2(3)) AS PARTITIONED,       CAST(NULL AS VARCHAR2(1)) AS TEMPORARY,       CAST(NULL AS VARCHAR2(1)) AS "GENERATED",       CAST(NULL AS VARCHAR2(1)) AS SECONDARY,       CAST(NULL AS VARCHAR2(7)) AS BUFFER_POOL,       CAST(NULL AS VARCHAR2(7)) AS FLASH_CACHE,       CAST(NULL AS VARCHAR2(7)) AS CELL_FLASH_CACHE,       CAST(NULL AS VARCHAR2(3)) AS USER_STATS,       CAST(NULL AS VARCHAR2(15)) AS DURATION,       CAST(NULL AS NUMBER) AS PCT_DIRECT_ACCESS,       CAST(NULL AS VARCHAR2(30)) AS ITYP_OWNER,       CAST(NULL AS VARCHAR2(30)) AS ITYP_NAME,       CAST(NULL AS VARCHAR2(1000)) AS PARAMETERS,       CAST(NULL AS VARCHAR2(3)) AS GLOBAL_STATS,       CAST(NULL AS VARCHAR2(12)) AS DOMIDX_STATUS,       CAST(NULL AS VARCHAR2(6)) AS DOMIDX_OPSTATUS,       CAST(FUNCIDX_STATUS AS VARCHAR2(8)) AS FUNCIDX_STATUS,       CAST('NO' AS VARCHAR2(3)) AS JOIN_INDEX,       CAST(NULL AS VARCHAR2(3)) AS IOT_REDUNDANT_PKEY_ELIM,       CAST(DROPPED AS VARCHAR2(9)) AS DROPPED,       CAST(VISIBILITY AS VARCHAR2(10)) AS VISIBILITY,       CAST(NULL AS VARCHAR2(14)) AS DOMIDX_MANAGEMENT,       CAST(NULL AS VARCHAR2(3)) AS SEGMENT_CREATED       FROM         (SELECT         DATABASE_NAME AS INDEX_OWNER,         CASE WHEN (TABLE_TYPE = 5 AND B.DATABASE_NAME !=  '__recyclebin') THEN SUBSTR(TABLE_NAME, 7 + INSTR(SUBSTR(TABLE_NAME, 7), '_'))              WHEN (TABLE_TYPE = 5 AND B.DATABASE_NAME =  '__recyclebin') THEN TABLE_NAME           ELSE (CONS_TAB.CONSTRAINT_NAME) END AS INDEX_NAME,          CASE           WHEN A.TABLE_TYPE = 5 AND EXISTS (             SELECT 1             FROM SYS.ALL_VIRTUAL_COLUMN_REAL_AGENT T_COL_INDEX,                  SYS.ALL_VIRTUAL_COLUMN_REAL_AGENT T_COL_BASE             WHERE T_COL_BASE.TABLE_ID = A.DATA_TABLE_ID               AND T_COL_BASE.COLUMN_NAME = T_COL_INDEX.COLUMN_NAME               AND T_COL_INDEX.TABLE_ID = A.TABLE_ID               AND T_COL_BASE.TENANT_ID = A.TENANT_ID               AND T_COL_INDEX.TENANT_ID = A.TENANT_ID               AND BITAND(T_COL_BASE.COLUMN_FLAGS,3) > 0           ) THEN 'FUNCTION-BASED NORMAL'           ELSE 'NORMAL'         END AS INDEX_TYPE_NAME,          DATABASE_NAME AS TABLE_OWNER,         CASE WHEN (TABLE_TYPE = 3) THEN A.TABLE_ID           ELSE A.DATA_TABLE_ID END AS TABLE_ID,         A.TABLE_ID AS INDEX_ID,         CASE WHEN TABLE_TYPE = 3 THEN 'UNIQUE'              WHEN A.INDEX_TYPE IN (2, 4, 8) THEN 'UNIQUE'           ELSE 'NONUNIQUE' END AS UNIQUENESS,         CASE WHEN A.COMPRESS_FUNC_NAME = NULL THEN 'DISABLED'           ELSE 'ENABLED' END AS COMPRESSION,         CASE WHEN TABLE_TYPE = 3 THEN 'VALID'              WHEN A.INDEX_STATUS = 2 THEN 'VALID'              WHEN A.INDEX_STATUS = 3 THEN 'CHECKING'              WHEN A.INDEX_STATUS = 4 THEN 'INELEGIBLE'              WHEN A.INDEX_STATUS = 5 THEN 'ERROR'           ELSE 'UNUSABLE' END AS STATUS,         A.INDEX_TYPE AS A_INDEX_TYPE,         A.PART_LEVEL AS A_PART_LEVEL,         A.TABLE_TYPE AS A_TABLE_TYPE,         CASE WHEN 0 = (SELECT COUNT(1) FROM SYS.ALL_VIRTUAL_COLUMN_REAL_AGENT                       WHERE TABLE_ID = A.TABLE_ID AND IS_HIDDEN = 0                         AND TENANT_ID = EFFECTIVE_TENANT_ID()) THEN 'ENABLED'           ELSE 'NULL' END AS FUNCIDX_STATUS,         CASE WHEN B.DATABASE_NAME = '__recyclebin' THEN 'YES'           ELSE 'NO' END AS DROPPED,         CASE WHEN BITAND(A.INDEX_ATTRIBUTES_SET, 1) = 0 THEN 'VISIBLE'           ELSE 'INVISIBLE' END AS VISIBILITY,         A.TABLESPACE_ID         FROM           SYS.ALL_VIRTUAL_TABLE_REAL_AGENT A           JOIN SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT B ON A.DATABASE_ID = B.DATABASE_ID           AND TABLE_TYPE IN (5, 3)           AND A.TENANT_ID = EFFECTIVE_TENANT_ID()           AND B.TENANT_ID = EFFECTIVE_TENANT_ID()           LEFT JOIN SYS.ALL_VIRTUAL_CONSTRAINT_REAL_AGENT CONS_TAB ON (CONS_TAB.TABLE_ID = A.TABLE_ID)               AND CONS_TAB.TENANT_ID = EFFECTIVE_TENANT_ID()         WHERE           NOT(TABLE_TYPE = 3 AND CONSTRAINT_NAME IS NULL) AND (CONS_TAB.CONSTRAINT_TYPE IS NULL OR CONS_TAB.CONSTRAINT_TYPE = 1)         ) C       JOIN SYS.ALL_VIRTUAL_TABLE_REAL_AGENT D ON C.TABLE_ID = D.TABLE_ID           AND D.TENANT_ID = EFFECTIVE_TENANT_ID()       LEFT JOIN SYS.ALL_VIRTUAL_TENANT_TABLESPACE_REAL_AGENT TP ON C.TABLESPACE_ID = TP.TABLESPACE_ID           AND TP.TENANT_ID = EFFECTIVE_TENANT_ID() )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::all_indexes_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_ALL_INDEXES_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_ALL_INDEXES_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT       CAST(INDEX_OWNER AS VARCHAR2(128)) AS OWNER,       CAST(INDEX_NAME AS VARCHAR2(128)) AS INDEX_NAME,       CAST(INDEX_TYPE_NAME AS VARCHAR2(27)) AS INDEX_TYPE,       CAST(TABLE_OWNER AS VARCHAR2(128)) AS TABLE_OWNER,       CAST(TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,       CAST('TABLE' AS CHAR(5)) AS TABLE_TYPE,       CAST(UNIQUENESS AS VARCHAR2(9)) AS UNIQUENESS,       CAST(COMPRESSION AS VARCHAR2(8)) AS COMPRESSION,       CAST(NULL AS NUMBER) AS PREFIX_LENGTH,       CAST(TP.TABLESPACE_NAME AS VARCHAR2(30)) AS TABLESPACE_NAME,       CAST(NULL AS NUMBER) AS INI_TRANS,       CAST(NULL AS NUMBER) AS MAX_TRANS,       CAST(NULL AS NUMBER) AS INITIAL_EXTENT,       CAST(NULL AS NUMBER) AS NEXT_EXTENT,       CAST(NULL AS NUMBER) AS MIN_EXTENTS,       CAST(NULL AS NUMBER) AS MAX_EXTENTS,       CAST(NULL AS NUMBER) AS PCT_INCREASE,       CAST(NULL AS NUMBER) AS PCT_THRESHOLD,       CAST(NULL AS NUMBER) AS INCLUDE_COLUMN,       CAST(NULL AS NUMBER) AS FREELISTS,       CAST(NULL AS NUMBER) AS FREELIST_GROUPS,       CAST(NULL AS NUMBER) AS PCT_FREE,       CAST(NULL AS VARCHAR2(3)) AS LOGGING,       CAST(NULL AS NUMBER) AS BLEVEL,       CAST(NULL AS NUMBER) AS LEAF_BLOCKS,       CAST(NULL AS NUMBER) AS DISTINCT_KEYS,       CAST(NULL AS NUMBER) AS AVG_LEAF_BLOCKS_PER_KEY,       CAST(NULL AS NUMBER) AS AVG_DATA_BLOCKS_PER_KEY,       CAST(NULL AS NUMBER) AS CLUSTERING_FACTOR,       CAST(STATUS AS VARCHAR2(10)) AS STATUS,       CAST(NULL AS NUMBER) AS NUM_ROWS,       CAST(NULL AS NUMBER) AS SAMPLE_SIZE,       CAST(NULL AS DATE) AS LAST_ANALYZED,       CAST(NULL AS VARCHAR2(40)) AS DEGREE,       CAST(NULL AS VARCHAR2(40)) AS INSTANCES,       CAST(CASE WHEN A_TABLE_TYPE = 3 THEN 'NO'                 WHEN A_INDEX_TYPE = 1 OR A_INDEX_TYPE = 2                 THEN (CASE WHEN D.PART_LEVEL = 0 THEN 'NO' ELSE 'YES' END)            ELSE (CASE WHEN A_PART_LEVEL = 0 THEN 'NO' ELSE 'YES' END) END  AS VARCHAR2(3)) AS PARTITIONED,       CAST(NULL AS VARCHAR2(1)) AS TEMPORARY,       CAST(NULL AS VARCHAR2(1)) AS "GENERATED",       CAST(NULL AS VARCHAR2(1)) AS SECONDARY,       CAST(NULL AS VARCHAR2(7)) AS BUFFER_POOL,       CAST(NULL AS VARCHAR2(7)) AS FLASH_CACHE,       CAST(NULL AS VARCHAR2(7)) AS CELL_FLASH_CACHE,       CAST(NULL AS VARCHAR2(3)) AS USER_STATS,       CAST(NULL AS VARCHAR2(15)) AS DURATION,       CAST(NULL AS NUMBER) AS PCT_DIRECT_ACCESS,       CAST(NULL AS VARCHAR2(30)) AS ITYP_OWNER,       CAST(NULL AS VARCHAR2(30)) AS ITYP_NAME,       CAST(NULL AS VARCHAR2(1000)) AS PARAMETERS,       CAST(NULL AS VARCHAR2(3)) AS GLOBAL_STATS,       CAST(NULL AS VARCHAR2(12)) AS DOMIDX_STATUS,       CAST(NULL AS VARCHAR2(6)) AS DOMIDX_OPSTATUS,       CAST(FUNCIDX_STATUS AS VARCHAR2(8)) AS FUNCIDX_STATUS,       CAST('NO' AS VARCHAR2(3)) AS JOIN_INDEX,       CAST(NULL AS VARCHAR2(3)) AS IOT_REDUNDANT_PKEY_ELIM,       CAST(DROPPED AS VARCHAR2(9)) AS DROPPED,       CAST(VISIBILITY AS VARCHAR2(10)) AS VISIBILITY,       CAST(NULL AS VARCHAR2(14)) AS DOMIDX_MANAGEMENT,       CAST(NULL AS VARCHAR2(3)) AS SEGMENT_CREATED       FROM         (SELECT         DATABASE_NAME AS INDEX_OWNER,         CASE WHEN (TABLE_TYPE = 5 AND B.DATABASE_NAME !=  '__recyclebin') THEN SUBSTR(TABLE_NAME, 7 + INSTR(SUBSTR(TABLE_NAME, 7), '_'))              WHEN (TABLE_TYPE = 5 AND B.DATABASE_NAME =  '__recyclebin') THEN TABLE_NAME           ELSE (CONS_TAB.CONSTRAINT_NAME) END AS INDEX_NAME,          CASE           WHEN A.TABLE_TYPE = 5 AND EXISTS (             SELECT 1             FROM SYS.ALL_VIRTUAL_COLUMN_REAL_AGENT T_COL_INDEX,                  SYS.ALL_VIRTUAL_COLUMN_REAL_AGENT T_COL_BASE             WHERE T_COL_BASE.TABLE_ID = A.DATA_TABLE_ID               AND T_COL_BASE.COLUMN_NAME = T_COL_INDEX.COLUMN_NAME               AND T_COL_INDEX.TABLE_ID = A.TABLE_ID               AND T_COL_BASE.TENANT_ID = A.TENANT_ID               AND T_COL_INDEX.TENANT_ID = A.TENANT_ID               AND BITAND(T_COL_BASE.COLUMN_FLAGS,3) > 0           ) THEN 'FUNCTION-BASED NORMAL'           ELSE 'NORMAL'         END AS INDEX_TYPE_NAME,          DATABASE_NAME AS TABLE_OWNER,         CASE WHEN (TABLE_TYPE = 3) THEN A.TABLE_ID           ELSE A.DATA_TABLE_ID END AS TABLE_ID,         A.TABLE_ID AS INDEX_ID,         CASE WHEN TABLE_TYPE = 3 THEN 'UNIQUE'              WHEN A.INDEX_TYPE IN (2, 4, 8) THEN 'UNIQUE'           ELSE 'NONUNIQUE' END AS UNIQUENESS,         CASE WHEN A.COMPRESS_FUNC_NAME = NULL THEN 'DISABLED'           ELSE 'ENABLED' END AS COMPRESSION,         CASE WHEN TABLE_TYPE = 3 THEN 'VALID'              WHEN A.INDEX_STATUS = 2 THEN 'VALID'              WHEN A.INDEX_STATUS = 3 THEN 'CHECKING'              WHEN A.INDEX_STATUS = 4 THEN 'INELEGIBLE'              WHEN A.INDEX_STATUS = 5 THEN 'ERROR'           ELSE 'UNUSABLE' END AS STATUS,         A.INDEX_TYPE AS A_INDEX_TYPE,         A.PART_LEVEL AS A_PART_LEVEL,         A.TABLE_TYPE AS A_TABLE_TYPE,         CASE WHEN 0 = (SELECT COUNT(1) FROM SYS.ALL_VIRTUAL_COLUMN_REAL_AGENT                         WHERE TABLE_ID = A.TABLE_ID AND IS_HIDDEN = 0                           AND TENANT_ID = EFFECTIVE_TENANT_ID()) THEN 'ENABLED'           ELSE 'NULL' END AS FUNCIDX_STATUS,         CASE WHEN B.DATABASE_NAME = '__recyclebin' THEN 'YES'           ELSE 'NO' END AS DROPPED,         CASE WHEN BITAND(A.INDEX_ATTRIBUTES_SET, 1) = 0 THEN 'VISIBLE'           ELSE 'INVISIBLE' END AS VISIBILITY,         A.TABLESPACE_ID         FROM           SYS.ALL_VIRTUAL_TABLE_REAL_AGENT A           JOIN SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT B ON A.DATABASE_ID = B.DATABASE_ID               AND A.TENANT_ID = EFFECTIVE_TENANT_ID()               AND B.TENANT_ID = EFFECTIVE_TENANT_ID()           AND (A.DATABASE_ID = USERENV('SCHEMAID')                OR USER_CAN_ACCESS_OBJ(1, DECODE(TABLE_TYPE, 3, A.TABLE_ID, 5, DATA_TABLE_ID), A.DATABASE_ID) = 1)           AND TABLE_TYPE IN (5, 3)           LEFT JOIN SYS.ALL_VIRTUAL_CONSTRAINT_REAL_AGENT CONS_TAB             ON (CONS_TAB.TABLE_ID = A.TABLE_ID AND CONS_TAB.TENANT_ID = EFFECTIVE_TENANT_ID())         WHERE           NOT(TABLE_TYPE = 3 AND CONSTRAINT_NAME IS NULL) AND (CONS_TAB.CONSTRAINT_TYPE IS NULL OR CONS_TAB.CONSTRAINT_TYPE = 1)         ) C       JOIN SYS.ALL_VIRTUAL_TABLE_REAL_AGENT D ON C.TABLE_ID = D.TABLE_ID                 AND D.TENANT_ID = EFFECTIVE_TENANT_ID()       LEFT JOIN SYS.ALL_VIRTUAL_TENANT_TABLESPACE_REAL_AGENT TP ON C.TABLESPACE_ID = TP.TABLESPACE_ID                 AND TP.TENANT_ID = EFFECTIVE_TENANT_ID() )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::user_indexes_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_USER_INDEXES_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_USER_INDEXES_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT       CAST(INDEX_NAME AS VARCHAR2(128)) AS INDEX_NAME,       CAST(INDEX_TYPE_NAME AS VARCHAR2(27)) AS INDEX_TYPE,       CAST(TABLE_OWNER AS VARCHAR2(128)) AS TABLE_OWNER,       CAST(TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,       CAST('TABLE' AS CHAR(5)) AS TABLE_TYPE,       CAST(UNIQUENESS AS VARCHAR2(9)) AS UNIQUENESS,       CAST(COMPRESSION AS VARCHAR2(8)) AS COMPRESSION,       CAST(NULL AS NUMBER) AS PREFIX_LENGTH,       CAST(TP.TABLESPACE_NAME AS VARCHAR2(30)) AS TABLESPACE_NAME,       CAST(NULL AS NUMBER) AS INI_TRANS,       CAST(NULL AS NUMBER) AS MAX_TRANS,       CAST(NULL AS NUMBER) AS INITIAL_EXTENT,       CAST(NULL AS NUMBER) AS NEXT_EXTENT,       CAST(NULL AS NUMBER) AS MIN_EXTENTS,       CAST(NULL AS NUMBER) AS MAX_EXTENTS,       CAST(NULL AS NUMBER) AS PCT_INCREASE,       CAST(NULL AS NUMBER) AS PCT_THRESHOLD,       CAST(NULL AS NUMBER) AS INCLUDE_COLUMN,       CAST(NULL AS NUMBER) AS FREELISTS,       CAST(NULL AS NUMBER) AS FREELIST_GROUPS,       CAST(NULL AS NUMBER) AS PCT_FREE,       CAST(NULL AS VARCHAR2(3)) AS LOGGING,       CAST(NULL AS NUMBER) AS BLEVEL,       CAST(NULL AS NUMBER) AS LEAF_BLOCKS,       CAST(NULL AS NUMBER) AS DISTINCT_KEYS,       CAST(NULL AS NUMBER) AS AVG_LEAF_BLOCKS_PER_KEY,       CAST(NULL AS NUMBER) AS AVG_DATA_BLOCKS_PER_KEY,       CAST(NULL AS NUMBER) AS CLUSTERING_FACTOR,       CAST(STATUS AS VARCHAR2(10)) AS STATUS,       CAST(NULL AS NUMBER) AS NUM_ROWS,       CAST(NULL AS NUMBER) AS SAMPLE_SIZE,       CAST(NULL AS DATE) AS LAST_ANALYZED,       CAST(NULL AS VARCHAR2(40)) AS DEGREE,       CAST(NULL AS VARCHAR2(40)) AS INSTANCES,       CAST(CASE WHEN A_TABLE_TYPE = 3 THEN 'NO'                 WHEN A_INDEX_TYPE = 1 OR A_INDEX_TYPE = 2                 THEN (CASE WHEN D.PART_LEVEL = 0 THEN 'NO' ELSE 'YES' END)            ELSE (CASE WHEN A_PART_LEVEL = 0 THEN 'NO' ELSE 'YES' END) END  AS VARCHAR2(3)) AS PARTITIONED,       CAST(NULL AS VARCHAR2(1)) AS TEMPORARY,       CAST(NULL AS VARCHAR2(1)) AS "GENERATED",       CAST(NULL AS VARCHAR2(1)) AS SECONDARY,       CAST(NULL AS VARCHAR2(7)) AS BUFFER_POOL,       CAST(NULL AS VARCHAR2(7)) AS FLASH_CACHE,       CAST(NULL AS VARCHAR2(7)) AS CELL_FLASH_CACHE,       CAST(NULL AS VARCHAR2(3)) AS USER_STATS,       CAST(NULL AS VARCHAR2(15)) AS DURATION,       CAST(NULL AS NUMBER) AS PCT_DIRECT_ACCESS,       CAST(NULL AS VARCHAR2(30)) AS ITYP_OWNER,       CAST(NULL AS VARCHAR2(30)) AS ITYP_NAME,       CAST(NULL AS VARCHAR2(1000)) AS PARAMETERS,       CAST(NULL AS VARCHAR2(3)) AS GLOBAL_STATS,       CAST(NULL AS VARCHAR2(12)) AS DOMIDX_STATUS,       CAST(NULL AS VARCHAR2(6)) AS DOMIDX_OPSTATUS,       CAST(FUNCIDX_STATUS AS VARCHAR2(8)) AS FUNCIDX_STATUS,       CAST('NO' AS VARCHAR2(3)) AS JOIN_INDEX,       CAST(NULL AS VARCHAR2(3)) AS IOT_REDUNDANT_PKEY_ELIM,       CAST(DROPPED AS VARCHAR2(9)) AS DROPPED,       CAST(VISIBILITY AS VARCHAR2(10)) AS VISIBILITY,       CAST(NULL AS VARCHAR2(14)) AS DOMIDX_MANAGEMENT,       CAST(NULL AS VARCHAR2(3)) AS SEGMENT_CREATED       FROM         (SELECT         DATABASE_NAME AS INDEX_OWNER,         CASE WHEN (TABLE_TYPE = 5 AND B.DATABASE_NAME !=  '__recyclebin') THEN SUBSTR(TABLE_NAME, 7 + INSTR(SUBSTR(TABLE_NAME, 7), '_'))              WHEN (TABLE_TYPE = 5 AND B.DATABASE_NAME =  '__recyclebin') THEN TABLE_NAME           ELSE (CONS_TAB.CONSTRAINT_NAME) END AS INDEX_NAME,          CASE           WHEN A.TABLE_TYPE = 5 AND EXISTS (             SELECT 1             FROM SYS.ALL_VIRTUAL_COLUMN_REAL_AGENT T_COL_INDEX,                  SYS.ALL_VIRTUAL_COLUMN_REAL_AGENT T_COL_BASE             WHERE T_COL_BASE.TABLE_ID = A.DATA_TABLE_ID               AND T_COL_BASE.COLUMN_NAME = T_COL_INDEX.COLUMN_NAME               AND T_COL_INDEX.TABLE_ID = A.TABLE_ID               AND T_COL_BASE.TENANT_ID = A.TENANT_ID               AND T_COL_INDEX.TENANT_ID = A.TENANT_ID               AND BITAND(T_COL_BASE.COLUMN_FLAGS,3) > 0           ) THEN 'FUNCTION-BASED NORMAL'           ELSE 'NORMAL'         END AS INDEX_TYPE_NAME,          DATABASE_NAME AS TABLE_OWNER,         CASE WHEN (TABLE_TYPE = 3) THEN A.TABLE_ID           ELSE A.DATA_TABLE_ID END AS TABLE_ID,         A.TABLE_ID AS INDEX_ID,         CASE WHEN TABLE_TYPE = 3 THEN 'UNIQUE'              WHEN A.INDEX_TYPE IN (2, 4, 8) THEN 'UNIQUE'           ELSE 'NONUNIQUE' END AS UNIQUENESS,         CASE WHEN A.COMPRESS_FUNC_NAME = NULL THEN 'DISABLED'           ELSE 'ENABLED' END AS COMPRESSION,         CASE WHEN TABLE_TYPE = 3 THEN 'VALID'              WHEN A.INDEX_STATUS = 2 THEN 'VALID'              WHEN A.INDEX_STATUS = 3 THEN 'CHECKING'              WHEN A.INDEX_STATUS = 4 THEN 'INELEGIBLE'              WHEN A.INDEX_STATUS = 5 THEN 'ERROR'           ELSE 'UNUSABLE' END AS STATUS,         A.INDEX_TYPE AS A_INDEX_TYPE,         A.PART_LEVEL AS A_PART_LEVEL,         A.TABLE_TYPE AS A_TABLE_TYPE,         CASE WHEN 0 = (SELECT COUNT(1) FROM SYS.ALL_VIRTUAL_COLUMN_REAL_AGENT                       WHERE TABLE_ID = A.TABLE_ID AND IS_HIDDEN = 0                         AND TENANT_ID = EFFECTIVE_TENANT_ID()) THEN 'ENABLED'           ELSE 'NULL' END AS FUNCIDX_STATUS,         CASE WHEN B.DATABASE_NAME = '__recyclebin' THEN 'YES'           ELSE 'NO' END AS DROPPED,         CASE WHEN BITAND(A.INDEX_ATTRIBUTES_SET, 1) = 0 THEN 'VISIBLE'           ELSE 'INVISIBLE' END AS VISIBILITY,         A.TABLESPACE_ID         FROM           SYS.ALL_VIRTUAL_TABLE_REAL_AGENT A           JOIN SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT B ON A.DATABASE_ID = USERENV('SCHEMAID') AND A.DATABASE_ID = B.DATABASE_ID           AND TABLE_TYPE IN (5, 3)           AND A.TENANT_ID = EFFECTIVE_TENANT_ID()           AND B.TENANT_ID = EFFECTIVE_TENANT_ID()           LEFT JOIN SYS.ALL_VIRTUAL_CONSTRAINT_REAL_AGENT CONS_TAB ON (CONS_TAB.TABLE_ID = A.TABLE_ID)               AND CONS_TAB.TENANT_ID = EFFECTIVE_TENANT_ID()         WHERE           NOT(TABLE_TYPE = 3 AND CONSTRAINT_NAME IS NULL) AND (CONS_TAB.CONSTRAINT_TYPE IS NULL OR CONS_TAB.CONSTRAINT_TYPE = 1)         ) C       JOIN SYS.ALL_VIRTUAL_TABLE_REAL_AGENT D ON C.TABLE_ID = D.TABLE_ID               AND D.TENANT_ID = EFFECTIVE_TENANT_ID()       LEFT JOIN SYS.ALL_VIRTUAL_TENANT_TABLESPACE_REAL_AGENT TP ON C.TABLESPACE_ID = TP.TABLESPACE_ID               AND TP.TENANT_ID = EFFECTIVE_TENANT_ID() )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::dba_cons_columns_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_DBA_CONS_COLUMNS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_DBA_CONS_COLUMNS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT       CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS OWNER,       CAST(SUBSTR(A.TABLE_NAME, 7 + INSTR(SUBSTR(A.TABLE_NAME, 7), '_')) AS VARCHAR2(128)) AS CONSTRAINT_NAME,       CAST(B.TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,       CAST(D.COLUMN_NAME AS VARCHAR2(4000)) AS COLUMN_NAME,       CAST(D.INDEX_POSITION AS NUMBER) AS POSITION       FROM SYS.ALL_VIRTUAL_TABLE_REAL_AGENT A, SYS.ALL_VIRTUAL_TABLE_REAL_AGENT B, SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT C, SYS.ALL_VIRTUAL_COLUMN_REAL_AGENT D       WHERE A.DATA_TABLE_ID = B.TABLE_ID AND A.DATABASE_ID = C.DATABASE_ID AND D.TABLE_ID = A.TABLE_ID AND A.INDEX_TYPE IN (2, 4, 8) AND C.DATABASE_NAME != '__recyclebin' AND D.IS_HIDDEN = 0 AND D.INDEX_POSITION != 0         AND A.TENANT_ID = EFFECTIVE_TENANT_ID()         AND B.TENANT_ID = EFFECTIVE_TENANT_ID()         AND C.TENANT_ID = EFFECTIVE_TENANT_ID()         AND D.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT       CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS OWNER,       CAST(A.FOREIGN_KEY_NAME AS VARCHAR2(128)) AS CONSTRAINT_NAME,       CAST(B.TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,       CAST(E.COLUMN_NAME AS VARCHAR2(4000)) AS COLUMN_NAME,       CAST(D.POSITION AS NUMBER) AS POSITION       FROM SYS.ALL_VIRTUAL_FOREIGN_KEY_REAL_AGENT A, SYS.ALL_VIRTUAL_TABLE_REAL_AGENT B, SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT C, SYS.ALL_VIRTUAL_FOREIGN_KEY_COLUMN_REAL_AGENT D, SYS.ALL_VIRTUAL_COLUMN_REAL_AGENT E       WHERE A.CHILD_TABLE_ID = B.TABLE_ID AND B.DATABASE_ID = C.DATABASE_ID AND A.FOREIGN_KEY_ID = D.FOREIGN_KEY_ID AND D.CHILD_COLUMN_ID = E.COLUMN_ID AND B.TABLE_ID = E.TABLE_ID         AND A.TENANT_ID = EFFECTIVE_TENANT_ID()         AND B.TENANT_ID = EFFECTIVE_TENANT_ID()         AND C.TENANT_ID = EFFECTIVE_TENANT_ID()         AND D.TENANT_ID = EFFECTIVE_TENANT_ID()         AND E.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT       CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS OWNER,       CAST(D.CONSTRAINT_NAME AS VARCHAR2(128)) AS CONSTRAINT_NAME,       CAST(A.TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,       CAST(B.COLUMN_NAME AS VARCHAR2(4000)) AS COLUMN_NAME,       CAST(B.ROWKEY_POSITION AS NUMBER) AS POSITION       FROM SYS.ALL_VIRTUAL_TABLE_REAL_AGENT A, SYS.ALL_VIRTUAL_COLUMN_REAL_AGENT B, SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT C, SYS.ALL_VIRTUAL_CONSTRAINT_REAL_AGENT D       WHERE A.TABLE_ID = D.TABLE_ID AND D.CONSTRAINT_TYPE = 1 AND A.TABLE_ID = B.TABLE_ID AND A.DATABASE_ID = C.DATABASE_ID AND B.ROWKEY_POSITION > 0 AND C.DATABASE_NAME != '__recyclebin' AND B.IS_HIDDEN = 0         AND A.TENANT_ID = EFFECTIVE_TENANT_ID()         AND B.TENANT_ID = EFFECTIVE_TENANT_ID()         AND C.TENANT_ID = EFFECTIVE_TENANT_ID()         AND D.TENANT_ID = EFFECTIVE_TENANT_ID() )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::all_cons_columns_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_ALL_CONS_COLUMNS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_ALL_CONS_COLUMNS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT       CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS OWNER,       CAST(SUBSTR(A.TABLE_NAME, 7 + INSTR(SUBSTR(A.TABLE_NAME, 7), '_')) AS VARCHAR2(128)) AS CONSTRAINT_NAME,       CAST(B.TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,       CAST(D.COLUMN_NAME AS VARCHAR2(4000)) AS COLUMN_NAME,       CAST(D.INDEX_POSITION AS NUMBER) AS POSITION       FROM SYS.ALL_VIRTUAL_TABLE_REAL_AGENT A, SYS.ALL_VIRTUAL_TABLE_REAL_AGENT B, SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT C, SYS.ALL_VIRTUAL_COLUMN_REAL_AGENT D       WHERE A.DATA_TABLE_ID = B.TABLE_ID         AND A.DATABASE_ID = C.DATABASE_ID         AND (A.DATABASE_ID = USERENV('SCHEMAID')             OR USER_CAN_ACCESS_OBJ(1, A.DATA_TABLE_ID, A.DATABASE_ID) = 1)         AND D.TABLE_ID = A.TABLE_ID         AND A.INDEX_TYPE IN (2, 4, 8)         AND C.DATABASE_NAME != '__recyclebin'         AND D.IS_HIDDEN = 0         AND D.INDEX_POSITION != 0     UNION ALL     SELECT       CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS OWNER,       CAST(A.FOREIGN_KEY_NAME AS VARCHAR2(128)) AS CONSTRAINT_NAME,       CAST(B.TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,       CAST(E.COLUMN_NAME AS VARCHAR2(4000)) AS COLUMN_NAME,       CAST(D.POSITION AS NUMBER) AS POSITION       FROM SYS.ALL_VIRTUAL_FOREIGN_KEY_REAL_AGENT A, SYS.ALL_VIRTUAL_TABLE_REAL_AGENT B, SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT C, SYS.ALL_VIRTUAL_FOREIGN_KEY_COLUMN_REAL_AGENT D, SYS.ALL_VIRTUAL_COLUMN_REAL_AGENT E       WHERE A.CHILD_TABLE_ID = B.TABLE_ID         AND B.DATABASE_ID = C.DATABASE_ID         AND (B.DATABASE_ID = USERENV('SCHEMAID')             OR USER_CAN_ACCESS_OBJ(1, A.CHILD_TABLE_ID, 1) = 1)         AND A.FOREIGN_KEY_ID = D.FOREIGN_KEY_ID         AND D.CHILD_COLUMN_ID = E.COLUMN_ID         AND B.TABLE_ID = E.TABLE_ID         AND A.TENANT_ID = EFFECTIVE_TENANT_ID()         AND B.TENANT_ID = EFFECTIVE_TENANT_ID()         AND C.TENANT_ID = EFFECTIVE_TENANT_ID()         AND D.TENANT_ID = EFFECTIVE_TENANT_ID()         AND E.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT       CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS OWNER,       CAST(D.CONSTRAINT_NAME AS VARCHAR2(128)) AS CONSTRAINT_NAME,       CAST(A.TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,       CAST(B.COLUMN_NAME AS VARCHAR2(4000)) AS COLUMN_NAME,       CAST(B.ROWKEY_POSITION AS NUMBER) AS POSITION       FROM SYS.ALL_VIRTUAL_TABLE_REAL_AGENT A, SYS.ALL_VIRTUAL_COLUMN_REAL_AGENT B, SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT C, SYS.ALL_VIRTUAL_CONSTRAINT_REAL_AGENT D       WHERE A.TABLE_ID = D.TABLE_ID         AND D.CONSTRAINT_TYPE = 1         AND A.TABLE_ID = B.TABLE_ID         AND A.DATABASE_ID = C.DATABASE_ID         AND (A.DATABASE_ID = USERENV('SCHEMAID')             OR USER_CAN_ACCESS_OBJ(1, A.TABLE_ID, 1) = 1)         AND B.ROWKEY_POSITION > 0         AND C.DATABASE_NAME != '__recyclebin' AND B.IS_HIDDEN = 0         AND A.TENANT_ID = EFFECTIVE_TENANT_ID()         AND B.TENANT_ID = EFFECTIVE_TENANT_ID()         AND C.TENANT_ID = EFFECTIVE_TENANT_ID()         AND D.TENANT_ID = EFFECTIVE_TENANT_ID() )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::user_cons_columns_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_USER_CONS_COLUMNS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_USER_CONS_COLUMNS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT       CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS OWNER,       CAST(SUBSTR(A.TABLE_NAME, 7 + INSTR(SUBSTR(A.TABLE_NAME, 7), '_')) AS VARCHAR2(128)) AS CONSTRAINT_NAME,       CAST(B.TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,       CAST(D.COLUMN_NAME AS VARCHAR2(4000)) AS COLUMN_NAME,       CAST(D.INDEX_POSITION AS NUMBER) AS POSITION       FROM SYS.ALL_VIRTUAL_TABLE_REAL_AGENT A, SYS.ALL_VIRTUAL_TABLE_REAL_AGENT B, SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT C, SYS.ALL_VIRTUAL_COLUMN_REAL_AGENT D       WHERE A.DATA_TABLE_ID = B.TABLE_ID AND A.DATABASE_ID = C.DATABASE_ID AND D.TABLE_ID = A.TABLE_ID AND A.INDEX_TYPE IN (2, 4, 8) AND C.DATABASE_NAME != '__recyclebin' AND D.IS_HIDDEN = 0 AND C.DATABASE_NAME = SYS_CONTEXT('USERENV','CURRENT_USER') AND D.INDEX_POSITION != 0         AND A.TENANT_ID = EFFECTIVE_TENANT_ID()         AND B.TENANT_ID = EFFECTIVE_TENANT_ID()         AND C.TENANT_ID = EFFECTIVE_TENANT_ID()         AND D.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT       CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS OWNER,       CAST(A.FOREIGN_KEY_NAME AS VARCHAR2(128)) AS CONSTRAINT_NAME,       CAST(B.TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,       CAST(E.COLUMN_NAME AS VARCHAR2(4000)) AS COLUMN_NAME,       CAST(D.POSITION AS NUMBER) AS POSITION       FROM SYS.ALL_VIRTUAL_FOREIGN_KEY_REAL_AGENT A, SYS.ALL_VIRTUAL_TABLE_REAL_AGENT B, SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT C, SYS.ALL_VIRTUAL_FOREIGN_KEY_COLUMN_REAL_AGENT D, SYS.ALL_VIRTUAL_COLUMN_REAL_AGENT E       WHERE A.CHILD_TABLE_ID = B.TABLE_ID AND B.DATABASE_ID = C.DATABASE_ID AND A.FOREIGN_KEY_ID = D.FOREIGN_KEY_ID AND D.CHILD_COLUMN_ID = E.COLUMN_ID AND B.TABLE_ID = E.TABLE_ID AND C.DATABASE_NAME = SYS_CONTEXT('USERENV','CURRENT_USER')         AND A.TENANT_ID = EFFECTIVE_TENANT_ID()         AND B.TENANT_ID = EFFECTIVE_TENANT_ID()         AND C.TENANT_ID = EFFECTIVE_TENANT_ID()         AND D.TENANT_ID = EFFECTIVE_TENANT_ID()         AND E.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT       CAST(C.DATABASE_NAME AS VARCHAR2(128)) AS OWNER,       CAST(D.CONSTRAINT_NAME AS VARCHAR2(128)) AS CONSTRAINT_NAME,       CAST(A.TABLE_NAME AS VARCHAR2(128)) AS TABLE_NAME,       CAST(B.COLUMN_NAME AS VARCHAR2(4000)) AS COLUMN_NAME,       CAST(B.ROWKEY_POSITION AS NUMBER) AS POSITION       FROM SYS.ALL_VIRTUAL_TABLE_REAL_AGENT A, SYS.ALL_VIRTUAL_COLUMN_REAL_AGENT B, SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT C, SYS.ALL_VIRTUAL_CONSTRAINT_REAL_AGENT D       WHERE A.TABLE_ID = D.TABLE_ID AND D.CONSTRAINT_TYPE = 1 AND A.TABLE_ID = B.TABLE_ID AND A.DATABASE_ID = C.DATABASE_ID AND B.ROWKEY_POSITION > 0 AND C.DATABASE_NAME != '__recyclebin' AND B.IS_HIDDEN = 0 AND C.DATABASE_NAME = SYS_CONTEXT('USERENV','CURRENT_USER')         AND A.TENANT_ID = EFFECTIVE_TENANT_ID()         AND B.TENANT_ID = EFFECTIVE_TENANT_ID()         AND C.TENANT_ID = EFFECTIVE_TENANT_ID()         AND D.TENANT_ID = EFFECTIVE_TENANT_ID() )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::user_segments_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_USER_SEGMENTS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_USER_SEGMENTS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT       CAST(A.SEGMENT_NAME AS VARCHAR2(128)) AS SEGMENT_NAME       ,CAST(A.PARTITION_NAME AS VARCHAR2(128)) AS PARTITION_NAME       ,CAST(A.SEGMENT_TYPE AS VARCHAR2(18)) AS SEGMENT_TYPE       ,CAST(NULL AS VARCHAR2(10)) AS SEGMENT_SUBTYPE       ,CAST(NULL AS VARCHAR2(30)) AS TABLESPACE_NAME       ,A.DATA_SIZE AS BYTES       ,A.BLOCK_SIZE AS BLOCKS       ,CAST(NULL AS NUMBER) AS EXTENTS       ,CAST(NULL AS NUMBER) AS INITIAL_EXTENT       ,CAST(NULL AS NUMBER) AS NEXT_EXTENT       ,CAST(NULL AS NUMBER) AS MIN_EXTENTS       ,CAST(NULL AS NUMBER) AS MAX_EXTENTS       ,CAST(NULL AS NUMBER) AS MAX_SIZE       ,CAST(NULL AS VARCHAR(7)) AS RETENTION       ,CAST(NULL AS NUMBER) AS MINRETENTION       ,CAST(NULL AS NUMBER) AS PCT_INCREASE       ,CAST(NULL AS NUMBER) AS FREELISTS       ,CAST(NULL AS NUMBER) AS FREELIST_GROUPS       ,CAST('DEFAULT' AS VARCHAR2(7)) AS BUFFER_POOL       ,CAST('DEFAULT' AS VARCHAR2(7)) AS FLASH_CACHE       ,CAST('DEFAULT' AS VARCHAR2(7)) AS CELL_FLASH_CACHE       FROM (       SELECT       T.TABLE_ID       ,T.DATABASE_ID       ,T.TABLE_NAME SEGMENT_NAME       ,NULL PARTITION_NAME       ,CASE WHEN T.TABLE_TYPE IN (0,2,3,6,8,9,10) THEN 'TABLE'           WHEN T.TABLE_TYPE IN (1,4) THEN 'VIEW'           WHEN T.TABLE_TYPE IN (5) THEN 'INDEX'           WHEN T.TABLE_TYPE IN (7) THEN 'MATERIALIZED VIEW'           ELSE NULL END AS SEGMENT_TYPE       ,T.BLOCK_SIZE       ,MT.DATA_SIZE       FROM       SYS.ALL_VIRTUAL_TABLE_REAL_AGENT T JOIN SYS.ALL_VIRTUAL_TENANT_META_TABLE_REAL_AGENT MT       ON T.TABLE_ID = MT.TABLE_ID WHERE T.PART_LEVEL=0 AND MT.ROLE = 1         AND T.TENANT_ID = EFFECTIVE_TENANT_ID()         AND MT.TENANT_ID = EFFECTIVE_TENANT_ID()       UNION ALL       SELECT           T.TABLE_ID           ,T.DATABASE_ID           ,T.TABLE_NAME SEGMENT_NAME           ,P.PART_NAME PARTITION_NAME           ,'TABLE PARTITION' AS SEGMENT_TYPE           ,T.BLOCK_SIZE           ,MT.DATA_SIZE           FROM SYS.ALL_VIRTUAL_TABLE_REAL_AGENT T JOIN SYS.ALL_VIRTUAL_PART_REAL_AGENT P ON T.TABLE_ID = P.TABLE_ID           JOIN SYS.ALL_VIRTUAL_TENANT_META_TABLE_REAL_AGENT MT           ON T.TABLE_ID = MT.TABLE_ID AND P.PART_ID = MT.PARTITION_ID WHERE T.PART_LEVEL=1 AND MT.ROLE = 1           AND T.TENANT_ID = EFFECTIVE_TENANT_ID()           AND P.TENANT_ID = EFFECTIVE_TENANT_ID()           AND MT.TENANT_ID = EFFECTIVE_TENANT_ID()       UNION ALL       SELECT           T.TABLE_ID           ,T.DATABASE_ID           ,T.TABLE_NAME SEGMENT_NAME           ,SUBP.SUB_PART_NAME PARTITION_NAME           ,'TABLE SUBPARTITION' AS OBJECT_TYPE           ,T.BLOCK_SIZE           ,MT.DATA_SIZE           FROM SYS.ALL_VIRTUAL_TABLE_REAL_AGENT T JOIN SYS.ALL_VIRTUAL_PART_REAL_AGENT P ON T.TABLE_ID =P.TABLE_ID JOIN SYS.ALL_VIRTUAL_SUB_PART_REAL_AGENT SUBP           ON P.TABLE_ID=SUBP.TABLE_ID AND P.PART_ID =SUBP.PART_ID           AND T.TENANT_ID = EFFECTIVE_TENANT_ID()           AND P.TENANT_ID = EFFECTIVE_TENANT_ID()           AND SUBP.TENANT_ID = EFFECTIVE_TENANT_ID()           JOIN (SELECT A.PARTITION_ID,A.TABLE_ID,A.DATA_SIZE,A.PART_ID,PARTITION_ID - 1152921504606846976 - PART_ID *4294967296 - 268435456 AS SUB_PART_ID FROM           (SELECT A.PARTITION_ID,A.TABLE_ID,A.DATA_SIZE,FLOOR((PARTITION_ID - 1152921504606846976 - 268435456)/4294967296) AS PART_ID FROM SYS.ALL_VIRTUAL_TENANT_META_TABLE_REAL_AGENT A                 WHERE A.PARTITION_ID != 0 AND A.ROLE = 1 AND A.TENANT_ID = EFFECTIVE_TENANT_ID())A) MT           ON SUBP.TABLE_ID = MT.TABLE_ID AND SUBP.PART_ID = MT.PART_ID AND SUBP.SUB_PART_ID=MT.SUB_PART_ID WHERE T.PART_LEVEL=2     )A WHERE DATABASE_ID=USERENV('SCHEMAID') )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::dba_segments_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_DBA_SEGMENTS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_DBA_SEGMENTS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT       B.DATABASE_NAME OWNER       ,CAST(A.SEGMENT_NAME AS VARCHAR2(128)) AS SEGMENT_NAME       ,CAST(A.PARTITION_NAME AS VARCHAR2(128)) AS PARTITION_NAME       ,CAST(A.SEGMENT_TYPE AS VARCHAR2(18)) AS SEGMENT_TYPE       ,CAST(NULL AS VARCHAR2(10)) AS SEGMENT_SUBTYPE       ,CAST(NULL AS VARCHAR2(30)) AS TABLESPACE_NAME       ,CAST(NULL AS NUMBER) AS HEADER_FILE       ,CAST(NULL AS NUMBER) AS HEADER_BLOCK       ,A.DATA_SIZE AS BYTES       ,A.BLOCK_SIZE AS BLOCKS       ,CAST(NULL AS NUMBER) AS EXTENTS       ,CAST(NULL AS NUMBER) AS INITIAL_EXTENT       ,CAST(NULL AS NUMBER) AS NEXT_EXTENT       ,CAST(NULL AS NUMBER) AS MIN_EXTENTS       ,CAST(NULL AS NUMBER) AS MAX_EXTENTS       ,CAST(NULL AS NUMBER) AS MAX_SIZE       ,CAST(NULL AS VARCHAR(7)) AS RETENTION       ,CAST(NULL AS NUMBER) AS MINRETENTION       ,CAST(NULL AS NUMBER) AS PCT_INCREASE       ,CAST(NULL AS NUMBER) AS FREELISTS       ,CAST(NULL AS NUMBER) AS FREELIST_GROUPS       ,CAST(NULL AS NUMBER) AS RELATIVE_FNO       ,CAST('DEFAULT' AS VARCHAR2(7)) AS BUFFER_POOL       ,CAST('DEFAULT' AS VARCHAR2(7)) AS FLASH_CACHE       ,CAST('DEFAULT' AS VARCHAR2(7)) AS CELL_FLASH_CACHE       FROM (       SELECT       T.TABLE_ID       ,T.DATABASE_ID       ,T.TABLE_NAME SEGMENT_NAME       ,NULL PARTITION_NAME       ,CASE WHEN T.TABLE_TYPE IN (0,2,3,6,8,9,10) THEN 'TABLE'           WHEN T.TABLE_TYPE IN (1,4) THEN 'VIEW'           WHEN T.TABLE_TYPE IN (5) THEN 'INDEX'           WHEN T.TABLE_TYPE IN (7) THEN 'MATERIALIZED VIEW'           ELSE NULL END AS SEGMENT_TYPE       ,T.BLOCK_SIZE       ,MT.DATA_SIZE       FROM       SYS.ALL_VIRTUAL_TABLE_REAL_AGENT T JOIN SYS.ALL_VIRTUAL_TENANT_META_TABLE_REAL_AGENT MT       ON T.TABLE_ID = MT.TABLE_ID WHERE T.PART_LEVEL=0 AND MT.ROLE = 1       AND T.TENANT_ID = EFFECTIVE_TENANT_ID()       AND MT.TENANT_ID = EFFECTIVE_TENANT_ID()       UNION ALL       SELECT           T.TABLE_ID           ,T.DATABASE_ID           ,T.TABLE_NAME SEGMENT_NAME           ,P.PART_NAME PARTITION_NAME           ,'TABLE PARTITION' AS SEGMENT_TYPE           ,T.BLOCK_SIZE           ,MT.DATA_SIZE           FROM SYS.ALL_VIRTUAL_TABLE_REAL_AGENT T JOIN SYS.ALL_VIRTUAL_PART_REAL_AGENT P ON T.TABLE_ID = P.TABLE_ID             AND T.TENANT_ID = EFFECTIVE_TENANT_ID()             AND P.TENANT_ID = EFFECTIVE_TENANT_ID()           JOIN SYS.ALL_VIRTUAL_TENANT_META_TABLE_REAL_AGENT MT           ON T.TABLE_ID = MT.TABLE_ID AND P.PART_ID = MT.PARTITION_ID WHERE T.PART_LEVEL=1 AND MT.ROLE = 1           AND MT.TENANT_ID = EFFECTIVE_TENANT_ID()       UNION ALL       SELECT           T.TABLE_ID           ,T.DATABASE_ID           ,T.TABLE_NAME SEGMENT_NAME           ,SUBP.SUB_PART_NAME PARTITION_NAME           ,'TABLE SUBPARTITION' AS OBJECT_TYPE           ,T.BLOCK_SIZE           ,MT.DATA_SIZE           FROM SYS.ALL_VIRTUAL_TABLE_REAL_AGENT T JOIN SYS.ALL_VIRTUAL_PART_REAL_AGENT P ON T.TABLE_ID =P.TABLE_ID JOIN SYS.ALL_VIRTUAL_SUB_PART_REAL_AGENT SUBP           ON P.TABLE_ID=SUBP.TABLE_ID AND P.PART_ID =SUBP.PART_ID           AND T.TENANT_ID = EFFECTIVE_TENANT_ID()           AND P.TENANT_ID = EFFECTIVE_TENANT_ID()           AND SUBP.TENANT_ID = EFFECTIVE_TENANT_ID()           JOIN (SELECT A.PARTITION_ID,A.TABLE_ID,A.DATA_SIZE,A.PART_ID,PARTITION_ID - 1152921504606846976 - PART_ID *4294967296 - 268435456 AS SUB_PART_ID FROM           (SELECT A.PARTITION_ID,A.TABLE_ID,A.DATA_SIZE,FLOOR((PARTITION_ID - 1152921504606846976 - 268435456)/4294967296) AS PART_ID FROM SYS.ALL_VIRTUAL_TENANT_META_TABLE_REAL_AGENT A               WHERE A.PARTITION_ID != 0 AND A.ROLE = 1 AND A.TENANT_ID = EFFECTIVE_TENANT_ID())A) MT           ON SUBP.TABLE_ID = MT.TABLE_ID AND SUBP.PART_ID = MT.PART_ID AND SUBP.SUB_PART_ID=MT.SUB_PART_ID WHERE T.PART_LEVEL=2     ) A JOIN SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT B       ON A.DATABASE_ID = B.DATABASE_ID       AND B.TENANT_ID = EFFECTIVE_TENANT_ID() )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::dba_types_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_DBA_TYPES_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_DBA_TYPES_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT       D.DATABASE_NAME AS OWNER,       T.TYPE_NAME AS TYPE_NAME,       T.TYPE_ID AS TYPE_OID,       CAST(         CASE T.TYPECODE         WHEN 1 THEN 'COLLECTION'         WHEN 2 THEN 'OBJECT' END AS VARCHAR2(10)) AS TYPECODE,       T.ATTRIBUTES AS ATTRIBUTES,       T.METHODS AS METHODS,       CAST('NO' AS CHAR(2)) AS PREDEFINED,       CAST('NO' AS CHAR(2)) AS INCOMPLETE,       CAST('YES' AS CHAR(3)) AS FINAL,       CAST('YES' AS CHAR(3)) AS INSTANTIABLE,       CAST(NULL AS VARCHAR2(30)) AS SUPERTYPE_OWNER,       CAST(NULL AS VARCHAR2(30)) AS SUPERTYPE_NAME,       T.LOCAL_ATTRS AS LOCAL_ATTRIBUTES,       T.LOCAL_METHODS AS LOCAL_METHODS,       T.TYPE_ID AS TYPEID     FROM       SYS.ALL_VIRTUAL_TYPE_REAL_AGENT T JOIN SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT D         ON D.DATABASE_ID = T.DATABASE_ID         AND T.TENANT_ID = SYS_CONTEXT('USERENV', 'CON_ID')         AND T.TENANT_ID = EFFECTIVE_TENANT_ID()         AND D.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT       CAST('SYS' AS VARCHAR2(30)) AS OWNER,       TS.TYPE_NAME AS TYPE_NAME,       TS.TYPE_ID AS TYPE_OID,       CAST(         CASE TS.TYPECODE         WHEN 1 THEN 'COLLECTION'         WHEN 2 THEN 'OBJECT' END AS VARCHAR2(10)) AS TYPECODE,       TS.ATTRIBUTES AS ATTRIBUTES,       TS.METHODS AS METHODS,       CAST('NO' AS CHAR(2)) AS PREDEFINED,       CAST('NO' AS CHAR(2)) AS INCOMPLETE,       CAST('YES' AS CHAR(3)) AS FINAL,       CAST('YES' AS CHAR(3)) AS INSTANTIABLE,       CAST(NULL AS VARCHAR2(30)) AS SUPERTYPE_OWNER,       CAST(NULL AS VARCHAR2(30)) AS SUPERTYPE_NAME,       TS.LOCAL_ATTRS AS LOCAL_ATTRIBUTES,       TS.LOCAL_METHODS AS LOCAL_METHODS,       TS.TYPE_ID AS TYPEID     FROM       SYS.ALL_VIRTUAL_TYPE_SYS_AGENT TS )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::all_types_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_ALL_TYPES_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_ALL_TYPES_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT       D.DATABASE_NAME AS OWNER,       T.TYPE_NAME AS TYPE_NAME,       T.TYPE_ID AS TYPE_OID,       CAST(         CASE T.TYPECODE         WHEN 1 THEN 'COLLECTION'         WHEN 2 THEN 'OBJECT' END AS VARCHAR2(10)) AS TYPECODE,       T.ATTRIBUTES AS ATTRIBUTES,       T.METHODS AS METHODS,       CAST('NO' AS CHAR(2)) AS PREDEFINED,       CAST('NO' AS CHAR(2)) AS INCOMPLETE,       CAST('YES' AS CHAR(3)) AS FINAL,       CAST('YES' AS CHAR(3)) AS INSTANTIABLE,       CAST(NULL AS VARCHAR2(30)) AS SUPERTYPE_OWNER,       CAST(NULL AS VARCHAR2(30)) AS SUPERTYPE_NAME,       T.LOCAL_ATTRS AS LOCAL_ATTRIBUTES,       T.LOCAL_METHODS AS LOCAL_METHODS,       T.TYPE_ID AS TYPEID     FROM       SYS.ALL_VIRTUAL_TYPE_REAL_AGENT T JOIN SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT D         ON D.DATABASE_ID = T.DATABASE_ID         AND T.TENANT_ID = EFFECTIVE_TENANT_ID()         AND D.TENANT_ID = EFFECTIVE_TENANT_ID()         AND (T.DATABASE_ID = USERENV('SCHEMAID')              or USER_CAN_ACCESS_OBJ(4, T.TYPE_ID, T.DATABASE_ID) = 1)         AND T.TENANT_ID = SYS_CONTEXT('USERENV', 'CON_ID')     UNION ALL     SELECT       CAST('SYS' AS VARCHAR2(30)) AS OWNER,       TS.TYPE_NAME AS TYPE_NAME,       TS.TYPE_ID AS TYPE_OID,       CAST(         CASE TS.TYPECODE         WHEN 1 THEN 'COLLECTION'         WHEN 2 THEN 'OBJECT' END AS VARCHAR2(10)) AS TYPECODE,       TS.ATTRIBUTES AS ATTRIBUTES,       TS.METHODS AS METHODS,       CAST('NO' AS CHAR(2)) AS PREDEFINED,       CAST('NO' AS CHAR(2)) AS INCOMPLETE,       CAST('YES' AS CHAR(3)) AS FINAL,       CAST('YES' AS CHAR(3)) AS INSTANTIABLE,       CAST(NULL AS VARCHAR2(30)) AS SUPERTYPE_OWNER,       CAST(NULL AS VARCHAR2(30)) AS SUPERTYPE_NAME,       TS.LOCAL_ATTRS AS LOCAL_ATTRIBUTES,       TS.LOCAL_METHODS AS LOCAL_METHODS,       TS.TYPE_ID AS TYPEID     FROM       SYS.ALL_VIRTUAL_TYPE_SYS_AGENT TS )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::user_types_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_USER_TYPES_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_USER_TYPES_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT       T.TYPE_NAME AS TYPE_NAME,       T.TYPE_ID AS TYPE_OID,       CAST(         CASE T.TYPECODE         WHEN 1 THEN 'COLLECTION'         WHEN 2 THEN 'OBJECT' END AS VARCHAR2(10)) AS TYPECODE,       T.ATTRIBUTES AS ATTRIBUTES,       T.METHODS AS METHODS,       CAST('NO' AS CHAR(2)) AS PREDEFINED,       CAST('NO' AS CHAR(2)) AS INCOMPLETE,       CAST('YES' AS CHAR(3)) AS FINAL,       CAST('YES' AS CHAR(3)) AS INSTANTIABLE,       CAST(NULL AS VARCHAR2(30)) AS SUPERTYPE_OWNER,       CAST(NULL AS VARCHAR2(30)) AS SUPERTYPE_NAME,       T.LOCAL_ATTRS AS LOCAL_ATTRIBUTES,       T.LOCAL_METHODS AS LOCAL_METHODS,       T.TYPE_ID AS TYPEID     FROM       SYS.ALL_VIRTUAL_TYPE_REAL_AGENT T JOIN SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT D         ON D.DATABASE_ID = T.DATABASE_ID            AND T.TENANT_ID = SYS_CONTEXT('USERENV', 'CON_ID')            AND D.DATABASE_ID = USERENV('SCHEMAID')            AND T.TENANT_ID = EFFECTIVE_TENANT_ID()            AND D.TENANT_ID = EFFECTIVE_TENANT_ID() )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::dba_type_attrs_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_DBA_TYPE_ATTRS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_DBA_TYPE_ATTRS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT /*+ USE_MERGE(T, A, D, T1, D1) */       D.DATABASE_NAME AS OWNER,       T.TYPE_NAME AS TYPE_NAME,       A.NAME AS ATTR_NAME,       CAST(NULL AS VARCHAR2(7)) AS ATTR_TYPE_MOD,       CAST(         CASE A.PROPERTIES         WHEN 3 THEN NULL         ELSE D1.DATABASE_NAME END AS VARCHAR2(128)) AS ATTR_TYPE_OWNER,       CAST(         CASE A.PROPERTIES         WHEN 3           THEN DECODE (BITAND(A.TYPE_ATTR_ID,1099511627775),             0,  'NULL',             1,  'NUMBER',             2,  'NUMBER',             3,  'NUMBER',             4,  'NUMBER',             5,  'NUMBER',             6,  'NUMBER',             7,  'NUMBER',             8,  'NUMBER',             9,  'NUMBER',             10, 'NUMBER',             11, 'BINARY_FLOAT',             12, 'BINARY_DOUBLE',             13, 'NUMBER',             14, 'NUMBER',             15, 'NUMBER',             16, 'NUMBER',             17, 'DATE',             18, 'TIMESTAMP',             19, 'DATE',             20, 'TIME',             21, 'YEAR',             22, 'VARCHAR2',             23, 'CHAR',             24, 'HEX_STRING',             25, 'EXT',             26, 'UNKNOWN',             27, 'TINYTEXT',             28, 'TEXT',             29, 'MEDIUMTEXT',             30,  DECODE(A.COLL_TYPE, 63, 'BLOB', 'CLOB'),             31, 'BIT',             32, 'ENUM',             33, 'SET',             34, 'ENUM_INNER',             35, 'SET_INNER',             36, CONCAT('TIMESTAMP(', CONCAT(A.SCALE, ') WITH TIME ZONE')),             37, CONCAT('TIMESTAMP(', CONCAT(A.SCALE, ') WITH LOCAL TIME ZONE')),             38, CONCAT('TIMESTAMP(', CONCAT(A.SCALE, ')')),             39, 'RAW',             40, CONCAT('INTERVAL YEAR(', CONCAT(A.SCALE, ') TO MONTH')),             41, CONCAT('INTERVAL DAY(', CONCAT(TRUNC(A.SCALE / 10), CONCAT(') TO SECOND(', CONCAT(MOD(A.SCALE, 10), ')')))),             42, 'FLOAT',             43, 'NVARCHAR2',             44, 'NCHAR',             45, '',             46, DECODE(A.COLL_TYPE, 63, 'BLOB', 'CLOB'),             'NOT_SUPPORT')         ELSE t1.TYPE_NAME END AS VARCHAR2(324)) AS ATTR_TYPE_NAME,       A.LENGTH AS LENGTH,       A.NUMBER_PRECISION AS NUMBER_PRECISION,       A.SCALE AS SCALE,       CAST('CHAR_CS' AS CHAR(7)) AS CHARACTER_SET_NAME,       A.ATTRIBUTE AS ATTR_NO,       CAST('NO' AS CHAR(2)) AS INHERITED,       CAST('C' AS CHAR(1)) AS CHAR_USED     FROM       SYS.ALL_VIRTUAL_TYPE_REAL_AGENT T JOIN SYS.ALL_VIRTUAL_TYPE_ATTR_REAL_AGENT A         ON T.TYPE_ID = A.TYPE_ID         AND T.TENANT_ID = EFFECTIVE_TENANT_ID()         AND A.TENANT_ID = EFFECTIVE_TENANT_ID()       JOIN SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT D         ON T.TENANT_ID = SYS_CONTEXT('USERENV', 'CON_ID')           AND t.database_id = d.database_id           AND D.TENANT_ID = EFFECTIVE_TENANT_ID()       LEFT JOIN SYS.ALL_VIRTUAL_TYPE_REAL_AGENT T1         ON T1.TYPE_ID = A.TYPE_ATTR_ID         AND T1.TENANT_ID = EFFECTIVE_TENANT_ID()       LEFT JOIN SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT D1         ON T1.DATABASE_ID = D1.DATABASE_ID         AND D1.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL     SELECT /*+ USE_MERGE(TS, TAS, TS1) */       CAST('SYS' AS VARCHAR2(30)) AS OWNER,       TS.TYPE_NAME AS TYPE_NAME,       TAS.NAME AS ATTR_NAME,       CAST(NULL AS VARCHAR2(7)) AS ATTR_TYPE_MOD,       CAST(         CASE TAS.PROPERTIES         WHEN 3 THEN NULL         ELSE 'SYS' END AS VARCHAR2(128)) AS ATTR_TYPE_OWNER,       CAST(         CASE TAS.PROPERTIES         WHEN 3           THEN DECODE (BITAND(TAS.TYPE_ATTR_ID,1099511627775),             0,  'NULL',             1,  'NUMBER',             2,  'NUMBER',             3,  'NUMBER',             4,  'NUMBER',             5,  'NUMBER',             6,  'NUMBER',             7,  'NUMBER',             8,  'NUMBER',             9,  'NUMBER',             10, 'NUMBER',             11, 'BINARY_FLOAT',             12, 'BINARY_DOUBLE',             13, 'NUMBER',             14, 'NUMBER',             15, 'NUMBER',             16, 'NUMBER',             17, 'DATE',             18, 'TIMESTAMP',             19, 'DATE',             20, 'TIME',             21, 'YEAR',             22, 'VARCHAR2',             23, 'CHAR',             24, 'HEX_STRING',             25, 'EXT',             26, 'UNKNOWN',             27, 'TINYTEXT',             28, 'TEXT',             29, 'MEDIUMTEXT',             30,  DECODE(TAS.COLL_TYPE, 63, 'BLOB', 'CLOB'),             31, 'BIT',             32, 'ENUM',             33, 'SET',             34, 'ENUM_INNER',             35, 'SET_INNER',             36, CONCAT('TIMESTAMP(', CONCAT(TAS.SCALE, ') WITH TIME ZONE')),             37, CONCAT('TIMESTAMP(', CONCAT(TAS.SCALE, ') WITH LOCAL TIME ZONE')),             38, CONCAT('TIMESTAMP(', CONCAT(TAS.SCALE, ')')),             39, 'RAW',             40, CONCAT('INTERVAL YEAR(', CONCAT(TAS.SCALE, ') TO MONTH')),             41, CONCAT('INTERVAL DAY(', CONCAT(TRUNC(TAS.SCALE / 10), CONCAT(') TO SECOND(', CONCAT(MOD(TAS.SCALE, 10), ')')))),             42, 'FLOAT',             43, 'NVARCHAR2',             44, 'NCHAR',             45, '',             46, DECODE(TAS.COLL_TYPE, 63, 'BLOB', 'CLOB'),             'NOT_SUPPORT')         ELSE TS1.TYPE_NAME END AS VARCHAR2(324)) AS ATTR_TYPE_NAME,       TAS.LENGTH AS LENGTH,       TAS.NUMBER_PRECISION AS NUMBER_PRECISION,       TAS.SCALE AS SCALE,       CAST('CHAR_CS' AS CHAR(7)) AS CHARACTER_SET_NAME,       TAS.ATTRIBUTE AS ATTR_NO,       CAST('NO' AS CHAR(2)) AS INHERITED,       CAST('C' AS CHAR(1)) AS CHAR_USED     FROM       SYS.ALL_VIRTUAL_TYPE_SYS_AGENT TS JOIN SYS.ALL_VIRTUAL_TYPE_ATTR_SYS_AGENT TAS         ON TS.TYPE_ID = TAS.TYPE_ID       LEFT JOIN SYS.ALL_VIRTUAL_TYPE_SYS_AGENT TS1         ON TS1.TYPE_ID = TAS.TYPE_ATTR_ID )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::all_type_attrs_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_ALL_TYPE_ATTRS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_ALL_TYPE_ATTRS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT /*+ USE_MERGE(T, A, D, T1, D1) */       D.DATABASE_NAME AS OWNER,       T.TYPE_NAME AS TYPE_NAME,       A.NAME AS ATTR_NAME,       CAST(NULL AS VARCHAR2(7)) AS ATTR_TYPE_MOD,       CAST(         CASE A.PROPERTIES         WHEN 3 THEN NULL         ELSE D1.DATABASE_NAME END AS VARCHAR2(128)) AS ATTR_TYPE_OWNER,       CAST(         CASE A.PROPERTIES         WHEN 3           THEN DECODE (BITAND(A.TYPE_ATTR_ID,1099511627775),             0,  'NULL',             1,  'NUMBER',             2,  'NUMBER',             3,  'NUMBER',             4,  'NUMBER',             5,  'NUMBER',             6,  'NUMBER',             7,  'NUMBER',             8,  'NUMBER',             9,  'NUMBER',             10, 'NUMBER',             11, 'BINARY_FLOAT',             12, 'BINARY_DOUBLE',             13, 'NUMBER',             14, 'NUMBER',             15, 'NUMBER',             16, 'NUMBER',             17, 'DATE',             18, 'TIMESTAMP',             19, 'DATE',             20, 'TIME',             21, 'YEAR',             22, 'VARCHAR2',             23, 'CHAR',             24, 'HEX_STRING',             25, 'EXT',             26, 'UNKNOWN',             27, 'TINYTEXT',             28, 'TEXT',             29, 'MEDIUMTEXT',             30,  DECODE(A.COLL_TYPE, 63, 'BLOB', 'CLOB'),             31, 'BIT',             32, 'ENUM',             33, 'SET',             34, 'ENUM_INNER',             35, 'SET_INNER',             36, CONCAT('TIMESTAMP(', CONCAT(A.SCALE, ') WITH TIME ZONE')),             37, CONCAT('TIMESTAMP(', CONCAT(A.SCALE, ') WITH LOCAL TIME ZONE')),             38, CONCAT('TIMESTAMP(', CONCAT(A.SCALE, ')')),             39, 'RAW',             40, CONCAT('INTERVAL YEAR(', CONCAT(A.SCALE, ') TO MONTH')),             41, CONCAT('INTERVAL DAY(', CONCAT(TRUNC(A.SCALE / 10), CONCAT(') TO SECOND(', CONCAT(MOD(A.SCALE, 10), ')')))),             42, 'FLOAT',             43, 'NVARCHAR2',             44, 'NCHAR',             45, '',             46, DECODE(A.COLL_TYPE, 63, 'BLOB', 'CLOB'),             'NOT_SUPPORT')         ELSE t1.TYPE_NAME END AS VARCHAR2(324)) AS ATTR_TYPE_NAME,       A.LENGTH AS LENGTH,       A.NUMBER_PRECISION AS NUMBER_PRECISION,       A.SCALE AS SCALE,       CAST('CHAR_CS' AS CHAR(7)) AS CHARACTER_SET_NAME,       A.ATTRIBUTE AS ATTR_NO,       CAST('NO' AS CHAR(2)) AS INHERITED,       CAST('C' AS CHAR(1)) AS CHAR_USED     FROM       SYS.ALL_VIRTUAL_TYPE_REAL_AGENT T JOIN SYS.ALL_VIRTUAL_TYPE_ATTR_REAL_AGENT A         ON T.TYPE_ID = A.TYPE_ID         AND T.TENANT_ID = EFFECTIVE_TENANT_ID()         AND A.TENANT_ID = EFFECTIVE_TENANT_ID()       JOIN SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT D         ON T.TENANT_ID = SYS_CONTEXT('USERENV', 'CON_ID')           AND t.database_id = d.database_id           AND D.TENANT_ID = EFFECTIVE_TENANT_ID()           and (t.database_id = USERENV('SCHEMAID')                or USER_CAN_ACCESS_OBJ(4, t.type_id, 1) = 1)       LEFT JOIN SYS.ALL_VIRTUAL_TYPE_REAL_AGENT T1         ON T1.TYPE_ID = A.TYPE_ATTR_ID         AND T1.TENANT_ID = EFFECTIVE_TENANT_ID()       LEFT JOIN SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT D1         ON T1.DATABASE_ID = D1.DATABASE_ID         AND D1.TENANT_ID = EFFECTIVE_TENANT_ID()     UNION ALL   SELECT /*+ USE_MERGE(TS, TAS, TS1) */       CAST('SYS' AS VARCHAR2(30)) AS OWNER,       TS.TYPE_NAME AS TYPE_NAME,       TAS.NAME AS ATTR_NAME,       CAST(NULL AS VARCHAR2(7)) AS ATTR_TYPE_MOD,       CAST(         CASE TAS.PROPERTIES         WHEN 3 THEN NULL         ELSE 'SYS' END AS VARCHAR2(128)) AS ATTR_TYPE_OWNER,       CAST(         CASE TAS.PROPERTIES         WHEN 3           THEN DECODE (BITAND(TAS.TYPE_ATTR_ID,1099511627775),             0,  'NULL',             1,  'NUMBER',             2,  'NUMBER',             3,  'NUMBER',             4,  'NUMBER',             5,  'NUMBER',             6,  'NUMBER',             7,  'NUMBER',             8,  'NUMBER',             9,  'NUMBER',             10, 'NUMBER',             11, 'BINARY_FLOAT',             12, 'BINARY_DOUBLE',             13, 'NUMBER',             14, 'NUMBER',             15, 'NUMBER',             16, 'NUMBER',             17, 'DATE',             18, 'TIMESTAMP',             19, 'DATE',             20, 'TIME',             21, 'YEAR',             22, 'VARCHAR2',             23, 'CHAR',             24, 'HEX_STRING',             25, 'EXT',             26, 'UNKNOWN',             27, 'TINYTEXT',             28, 'TEXT',             29, 'MEDIUMTEXT',             30,  DECODE(TAS.COLL_TYPE, 63, 'BLOB', 'CLOB'),             31, 'BIT',             32, 'ENUM',             33, 'SET',             34, 'ENUM_INNER',             35, 'SET_INNER',             36, CONCAT('TIMESTAMP(', CONCAT(TAS.SCALE, ') WITH TIME ZONE')),             37, CONCAT('TIMESTAMP(', CONCAT(TAS.SCALE, ') WITH LOCAL TIME ZONE')),             38, CONCAT('TIMESTAMP(', CONCAT(TAS.SCALE, ')')),             39, 'RAW',             40, CONCAT('INTERVAL YEAR(', CONCAT(TAS.SCALE, ') TO MONTH')),             41, CONCAT('INTERVAL DAY(', CONCAT(TRUNC(TAS.SCALE / 10), CONCAT(') TO SECOND(', CONCAT(MOD(TAS.SCALE, 10), ')')))),             42, 'FLOAT',             43, 'NVARCHAR2',             44, 'NCHAR',             45, '',             46, DECODE(TAS.COLL_TYPE, 63, 'BLOB', 'CLOB'),             'NOT_SUPPORT')         ELSE TS1.TYPE_NAME END AS VARCHAR2(324)) AS ATTR_TYPE_NAME,       TAS.LENGTH AS LENGTH,       TAS.NUMBER_PRECISION AS NUMBER_PRECISION,       TAS.SCALE AS SCALE,       CAST('CHAR_CS' AS CHAR(7)) AS CHARACTER_SET_NAME,       TAS.ATTRIBUTE AS ATTR_NO,       CAST('NO' AS CHAR(2)) AS INHERITED,       CAST('C' AS CHAR(1)) AS CHAR_USED     FROM       SYS.ALL_VIRTUAL_TYPE_SYS_AGENT TS JOIN SYS.ALL_VIRTUAL_TYPE_ATTR_SYS_AGENT TAS         ON TS.TYPE_ID = TAS.TYPE_ID       LEFT JOIN SYS.ALL_VIRTUAL_TYPE_SYS_AGENT TS1         ON TS1.TYPE_ID = TAS.TYPE_ATTR_ID )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}

int ObInnerTableSchema::user_type_attrs_schema(ObTableSchema &table_schema)
{
  int ret = OB_SUCCESS;
  uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1;

  //generated fields:
  table_schema.set_tenant_id(OB_SYS_TENANT_ID);
  table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
  table_schema.set_database_id(combine_id(OB_SYS_TENANT_ID, OB_ORA_SYS_DATABASE_ID));
  table_schema.set_table_id(combine_id(OB_SYS_TENANT_ID, OB_USER_TYPE_ATTRS_TID));
  table_schema.set_rowkey_split_pos(0);
  table_schema.set_is_use_bloomfilter(false);
  table_schema.set_progressive_merge_num(0);
  table_schema.set_rowkey_column_num(0);
  table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK);
  table_schema.set_table_type(SYSTEM_VIEW);
  table_schema.set_index_type(INDEX_TYPE_IS_NOT);
  table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_table_name(OB_USER_TYPE_ATTRS_TNAME))) {
      LOG_ERROR("fail to set table_name", K(ret));
    }
  }

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) {
      LOG_ERROR("fail to set compress_func_name", K(ret));
    }
  }
  table_schema.set_part_level(PARTITION_LEVEL_ZERO);
  table_schema.set_charset_type(ObCharset::get_default_charset());
  table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
  table_schema.set_create_mem_version(1);

  if (OB_SUCC(ret)) {
    if (OB_FAIL(table_schema.set_view_definition(R"__(     SELECT /*+ USE_MERGE(T, A, D, T1, D1) */       T.TYPE_NAME AS TYPE_NAME,       A.NAME AS ATTR_NAME,       CAST(NULL AS VARCHAR2(7)) AS ATTR_TYPE_MOD,       CAST(         CASE A.PROPERTIES         WHEN 3 THEN NULL         ELSE D1.DATABASE_NAME END AS VARCHAR2(128)) AS ATTR_TYPE_OWNER,       CAST(         CASE A.PROPERTIES         WHEN 3           THEN DECODE (BITAND(A.TYPE_ATTR_ID,1099511627775),             0,  'NULL',             1,  'NUMBER',             2,  'NUMBER',             3,  'NUMBER',             4,  'NUMBER',             5,  'NUMBER',             6,  'NUMBER',             7,  'NUMBER',             8,  'NUMBER',             9,  'NUMBER',             10, 'NUMBER',             11, 'BINARY_FLOAT',             12, 'BINARY_DOUBLE',             13, 'NUMBER',             14, 'NUMBER',             15, 'NUMBER',             16, 'NUMBER',             17, 'DATE',             18, 'TIMESTAMP',             19, 'DATE',             20, 'TIME',             21, 'YEAR',             22, 'VARCHAR2',             23, 'CHAR',             24, 'HEX_STRING',             25, 'EXT',             26, 'UNKNOWN',             27, 'TINYTEXT',             28, 'TEXT',             29, 'MEDIUMTEXT',             30,  DECODE(A.COLL_TYPE, 63, 'BLOB', 'CLOB'),             31, 'BIT',             32, 'ENUM',             33, 'SET',             34, 'ENUM_INNER',             35, 'SET_INNER',             36, CONCAT('TIMESTAMP(', CONCAT(A.SCALE, ') WITH TIME ZONE')),             37, CONCAT('TIMESTAMP(', CONCAT(A.SCALE, ') WITH LOCAL TIME ZONE')),             38, CONCAT('TIMESTAMP(', CONCAT(A.SCALE, ')')),             39, 'RAW',             40, CONCAT('INTERVAL YEAR(', CONCAT(A.SCALE, ') TO MONTH')),             41, CONCAT('INTERVAL DAY(', CONCAT(TRUNC(A.SCALE / 10), CONCAT(') TO SECOND(', CONCAT(MOD(A.SCALE, 10), ')')))),             42, 'FLOAT',             43, 'NVARCHAR2',             44, 'NCHAR',             45, '',             46, DECODE(A.COLL_TYPE, 63, 'BLOB', 'CLOB'),             'NOT_SUPPORT')         ELSE t1.TYPE_NAME END AS VARCHAR2(324)) AS ATTR_TYPE_NAME,       A.LENGTH AS LENGTH,       A.NUMBER_PRECISION AS NUMBER_PRECISION,       A.SCALE AS SCALE,       CAST('CHAR_CS' AS CHAR(7)) AS CHARACTER_SET_NAME,       A.ATTRIBUTE AS ATTR_NO,       CAST('NO' AS CHAR(2)) AS INHERITED,       CAST('C' AS CHAR(1)) AS CHAR_USED     FROM       SYS.ALL_VIRTUAL_TYPE_REAL_AGENT T JOIN SYS.ALL_VIRTUAL_TYPE_ATTR_REAL_AGENT A         ON T.TYPE_ID = A.TYPE_ID         AND T.TENANT_ID = EFFECTIVE_TENANT_ID()         AND A.TENANT_ID = EFFECTIVE_TENANT_ID()       JOIN SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT D         ON T.TENANT_ID = SYS_CONTEXT('USERENV', 'CON_ID')         AND T.DATABASE_ID = D.DATABASE_ID         AND D.TENANT_ID = EFFECTIVE_TENANT_ID()         AND D.DATABASE_ID = USERENV('SCHEMAID')       LEFT JOIN SYS.ALL_VIRTUAL_TYPE_REAL_AGENT T1         ON T1.TYPE_ID = A.TYPE_ATTR_ID         AND T1.TENANT_ID = EFFECTIVE_TENANT_ID()       LEFT JOIN SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT D1         ON T1.DATABASE_ID = D1.DATABASE_ID         AND D1.TENANT_ID = EFFECTIVE_TENANT_ID() )__"))) {
      LOG_ERROR("fail to set view_definition", K(ret));
    }
  }
  table_schema.set_index_using_type(USING_BTREE);
  table_schema.set_row_store_type(FLAT_ROW_STORE);
  table_schema.set_store_format(OB_STORE_FORMAT_COMPACT_MYSQL);
  table_schema.set_progressive_merge_round(1);
  table_schema.set_storage_format_version(3);

  table_schema.set_max_used_column_id(column_id);
  table_schema.get_part_option().set_max_used_part_id(table_schema.get_part_option().get_part_num() - 1);
  table_schema.get_part_option().set_partition_cnt_within_partition_table(OB_ALL_CORE_TABLE_TID == common::extract_pure_id(table_schema.get_table_id()) ? 1 : 0);
  return ret;
}


} // end namespace share
} // end namespace oceanbase
